这个问题已经被问了一遍又一遍,但无论解决方案是在别人的项目,它不适合我。
我有一个从客户端调用服务的WsDualHttpBinding。我的客户端配置是这样的:
<bindings>
<wsDualHttpBinding>
<binding name="wsDualHttpBindingConfiguration" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:05:00" bypassProxyOnLocal="true" />
</wsDualHttpBinding>
</bindings>
我的客户端是这样定义的:
<client>
<endpoint address="http://{ipadress}:60379/ConfigurationCompleterService.svc"
binding="wsDualHttpBinding" bindingConfiguration="wsDualHttpBindingConfiguration"
contract="InfluxConfigurationCompleterService.IConfigurationCompleterService"
name="WSDualHttpBinding_IConfigurationCompleterService">
<identity>
<userPrincipalName value="{domain-username}" />
</identity>
</endpoint>
<!--wsDualHttpBindingConfiguration-->
<endpoint address="http://{ipadress}:60379/ConfigurationImportService.svc"
binding="wsDualHttpBinding" bindingConfiguration="wsDualHttpBindingConfiguration"
contract="ConfigurationImportServiceReference.IConfigurationImportService"
name="WSDualHttpBinding_IConfigurationImportService">
<identity>
<userPrincipalName value="{domain-username}" />
</identity>
</endpoint>
</client>
这个在本地模式下工作,在同一台机器上。当我在服务器上部署服务并启动我的客户端时,我在1分钟超时后得到以下错误消息:
未处理异常:System.ServiceModel.CommunicationException:安全协商失败,因为远程方没有及时发送回复。这可能是因为底层传输连接被中止。
我理解这个问题是由于端口(但在这里我部署它,特别是在不同的端口80)或安全问题。
所以我尝试在我的绑定配置中插入安全属性:
<security mode="none" />
<security mode="message"><message clientCredentialType="None"/></security>
和其他我不记得的。我不能得到我的服务,即使在同一台机器上,一旦我部署它,而它在VS2012上工作得很好。
我的服务托管得很好,我可以从web浏览器和远程机器访问它们。
提前感谢。
PS:有没有办法配置WsDualHttpBinding在一个绝对不安全的方式,不会问任何凭据?我有同样的问题,但这是因为我的客户端代码。例如:
WSDualHttpBinding binding = new WSDualHttpBinding();
binding.Security.Mode = WSDualHttpSecurityMode.None; <-- I forgot this line.
EndpointAddress endpoint = new EndpointAddress("http://localhost/CardService.svc");
DuplexChannelFactory<ICardService> channelFactory = new DuplexChannelFactory<ICardService>(this, binding, endpoint);
ICardService channel = channelFactory.CreateChannel();
string message = "Hello, service.";
Console.WriteLine("Successfully created the channel. Pinging it with message "{0}".", message);
channel.Ping(message);
Console.WriteLine("Successfully pinged the channel.");