我有一个 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。请验证 EndpointAddress 指定或暗示的 EndpointIdentity 是否正确标识了远程端点。
服务的服务器绑定如下所示:
<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">
?