【发布时间】:2013-09-04 18:47:05
【问题描述】:
我有一个 WCF 服务,它为不同的 WCF 服务提供身份验证/授权。
这是一个示例方法:
public int AddCustomerStopInfo(CustomerStop stop)
{
var request = new AddCustomerStopInfoRequest(stop);
var service = new ChannelFactory<IAccountManagementChannel>("WSHttpBinding_IAccountManagement").CreateChannel();
try
{
var response = service.AddCustomerStopInfo(request);
service.Close();
return response.AddCustomerStopInfoResult;
}
catch (CommunicationException e)
{
service.Abort();
throw;
}
}
在 service.AddCustomerStopInfo() 方法调用中,抛出异常。消息内容如下:
无法打开安全通道,因为与 远程端点失败。这可能是由于缺席或不正确 EndpointAddress 中指定的 EndpointIdentity 用于创建 渠道。请验证指定或暗示的 EndpointIdentity EndpointAddress 正确识别远程端点。
服务的服务器绑定如下:
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IAccountManagement" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="100065536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="None" />
</binding>
...
<services>
<service behaviorConfiguration="ABCD.Service.Service1Behavior"
name="ABCD.Service.AccountManagement">
<endpoint address="" behaviorConfiguration="ValidationBehavior"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IAccountManagement"
name="WSHttpBinding_IAccountManagement" contract="ABCD.Service.IAccountManagement">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" behaviorConfiguration="" binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
和客户端:
<client>
<endpoint address="[site location]/AccountManagement.svc"
binding="wsHttpBinding"
contract="IAccountManagement" name="WSHttpBinding_IAccountManagement">
</endpoint>
</client>
两个服务都在同一台服务器上。如果其他服务有<security mode="None">,我不明白为什么我会收到此错误?
【问题讨论】:
-
您有服务器的安全证书吗?是自签吗?您是否指定了
https地址?您输入的用户名和密码是否正确? -
是的,有一个证书,是的,它是自签名的。 (这是在测试环境中。)我没有指定 https。让我试试这些然后回复你 - 我不认为这是一个问题。
-
你有一个
wsHttpBinding,所以你应该使用https,尽管它不是强制性的。如果您在测试环境中,您可能必须添加代码以允许与测试服务器建立许可连接。 -
设置 Https 并添加许可连接解决了这个问题。如果您将其写为答案,我会为您标记。感谢您的帮助。
标签: wcf wcf-binding