我似乎发现了这一点。我发现很难用Visual Studio中的WCF配置编辑器来正确处理。最好是复制并粘贴它。
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="CustomDualBinding">
<security mode="None" />
</binding>
</wsDualHttpBinding>
</bindings>
<services>
<service name="WCFServiceWebRoleStockTrading.Service">
<endpoint address="" binding="wsDualHttpBinding" bindingConfiguration="CustomDualBinding"
contract="WCFServiceWebRoleStockTrading.IService" />
</service>
</services>
...
</system.serviceModel>
在客户端中,确保您的配置中包含以下内容:
Uri baseAddress = new Uri("http://xxx.cloudapp.net/Service.svc");
WSDualHttpBinding wsd = new WSDualHttpBinding();
wsd.Security = new WSDualHttpSecurity() { Mode = WSDualHttpSecurityMode.None, Message = new MessageSecurityOverHttp() { ClientCredentialType = MessageCredentialType.None, NegotiateServiceCredential = false } };
EndpointAddress ea = new EndpointAddress(baseAddress);
InstanceContext site = new InstanceContext(this);
_client = new ServiceClient(site, wsd, ea);