您的位置:首页 > 理论基础 > 计算机网络

wcfDualHTTPBinding配置的服务器与客户端部署于不同机器的问题

2016-04-22 14:50 483 查看
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" />
</system.web>

<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsDualHttpBinding>
<binding name="dualHttpBinding" transactionFlow="true" maxReceivedMessageSize="100000"
messageEncoding="Text" >
<security mode="None">
<message clientCredentialType="None" negotiateServiceCredential="false" />
</security>
</binding>
</wsDualHttpBinding>
</bindings>

<services>
<service behaviorConfiguration="MyServiceBehavior" name="service.MyPublisher" >
<endpoint address="" binding="wsDualHttpBinding" contract="service.IMyContract" bindingConfiguration="dualHttpBinding">
<!--<identity>
<dns value="localhost"/>
</identity>-->

</endpoint>
<!--<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />-->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://192.168.0.139:8899/" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>

以上是wsDualHTTPBinding的配置文件,wsDualHTTPBinding用于实现双向通信。红色部分加入之后,可以将服务器与客户端软件部署于不同的机器上(蓝色部分去除)。
如果没有下面这段红色部分:
<security mode="None"> <message clientCredentialType="None" negotiateServiceCredential="false" /> </security>客户端会出现如下异常报错:
The caller was not authenticated by the service.
部署于不同机器的另外一个需要注意的地方是:关闭防火墙。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  wcfDualHTTPBinding