我有一个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中缺少或指定了错误的EndpointAddress。请验证由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">,我不明白为什么会收到这个错误?
发布于 2013-09-04 19:33:45
当您试图通过wsHttpBinding使用安全绑定时,您将需要通过https连接到服务器,并使用调试代码允许允许连接到测试服务器。
这是因为您将只有一个自签名证书,而且https在安全证书方面非常严格。
https://stackoverflow.com/questions/18621510
复制相似问题