问题描述
|
我正在尝试让客户端连接到Windows服务中托管的WCF服务。客户端运行在没有网络和域的计算机上,即Win XP SP3。该计算机正在运行Win XP SP3的VM,并且正在运行前面提到的WCF服务。 VM配置为“与主机共享网络”。两台机器可以互相ping通。
我尝试将服务同时作为LocalService运行,并使用真实计算机和VM上的用户帐户/密码运行。
<?xml version=\"1.0\"?>
<configuration>
<configSections>
<sectionGroup name=\"applicationSettings\" type=\"System.Configuration.ApplicationSettingsGroup,System,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089\" >
<section name=\"DllAnalyzer.DllAnalyzerClient.Properties.Settings\" type=\"System.Configuration.ClientSettingsSection,PublicKeyToken=b77a5c561934e089\" requirePermission=\"false\" />
</sectionGroup>
<section name=\"log4net\" type=\"log4net.Config.Log4NetConfigurationSectionHandler,log4net\" />
</configSections>
<system.serviceModel>
<client>
<!--This is the endpoint to the VM Running the service -->
<endpoint address=\"http://192.168.224.1:8001/DllAnalyzerService/\"
binding=\"wsDualHttpBinding\" bindingConfiguration=\"WSDualHttpBinding_IDllAnalyzerService\"
contract=\"AnalyzerServiceReference.IDllAnalyzerService\" name=\"WSDualHttpBinding_IDllAnalyzerService\">
<identity>-->
<dns value=\"localhost\" />
</identity>
</endpoint>
</client>
<bindings>
<wsDualHttpBinding>
<binding name=\"WSDualHttpBinding_IDllAnalyzerService\" closeTimeout=\"00:01:00\"
openTimeout=\"00:01:00\" sendTimeout=\"00:01:00\"
bypassproxyOnLocal=\"false\" transactionFlow=\"false\" hostNameComparisonMode=\"StrongWildcard\"
maxBufferPoolSize=\"524288\" maxReceivedMessageSize=\"65536\"
messageEncoding=\"Text\" textEncoding=\"utf-8\" useDefaultWebProxy=\"true\">
<readerQuotas maxDepth=\"32\" maxStringContentLength=\"8192\" maxArrayLength=\"16384\"
maxBytesPerRead=\"4096\" maxNaMetableCharCount=\"16384\" />
<reliableSession ordered=\"true\" />
<security mode=\"Message\">
<message clientCredentialType=\"Windows\" negotiateServiceCredential=\"true\"
algorithmSuite=\"Default\" />
</security>
</binding>
</wsDualHttpBinding>
</bindings>
</system.serviceModel>
<startup><supportedRuntime version=\"v4.0\" sku=\".NETFramework,Version=v4.0\"/></startup><applicationSettings>
<DllAnalyzer.DllAnalyzerClient.Properties.Settings>
<setting name=\"UseSelfHostingService\" serializeAs=\"String\">
<value>True</value>
</setting>
</DllAnalyzer.DllAnalyzerClient.Properties.Settings>
</applicationSettings>
<log4net>
<appender name=\"LogFileAppender\" type=\"log4net.Appender.FileAppender\">
<param name=\"File\" value=\"${USERPROFILE}\\DLL Analysis Logs\\ClientLog.txt\" />
<param name=\"AppendToFile\" value=\"true\" />
<layout type=\"log4net.Layout.PatternLayout\">
<param name=\"Header\" value=\"[Header]
\" />
<param name=\"Footer\" value=\"[Footer]
\" />
<param name=\"ConversionPattern\" value=\"%d [%t] %-5p %c %m%n\" />
</layout>
</appender>
<root>
<level value=\"DEBUG\" />
<appender-ref ref=\"LogFileAppender\" />
</root>
</log4net>
</configuration>
我在没有网络连接的另一台机器上运行VM
解决方法
您的问题是您已使用客户端的Windows凭据在wsHttp绑定上配置了消息安全性,但是服务器无法识别客户端的Windows凭据,因为服务器之间没有域信任关系客户端VM上的域和本地安全机构。
如果虚拟机无法与服务器加入同一域,则需要更改为使用其他证书(例如客户端证书)或禁用消息安全性。