客户端调用主机的wcf服务中出现了securitynegotiationexception的异常,后来发现是主机的app.config中wcf服务的配置有些问题
app.config中
<services>
<service name="TestApplication.ModuleService">
<endpoint address="" binding="wsHttpBinding" contract="TestApplication.IModuleService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8081/ModuleService/" />
</baseAddresses>
</host>
</service><pre name="code" class="html">
其中的wsHttpBinding有些问题,改成basicHttpBinding
<services>
<service name="TestApplication.ModuleService">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="ModuleBinding" contract="TestApplication.IModuleService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8081/ModuleService/" />
</baseAddresses>
</host>
</service>
<bindings>
<basicHttpBinding>
<binding name="ModuleBinding" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
useDefaultWebProxy="true">
<security>
<transport realm="" />
</security>
</binding>
</bindings>
经测试可以成功调用了