首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WCF -获取CommunicationException

WCF -获取CommunicationException
EN

Stack Overflow用户
提问于 2013-09-04 18:47:05
回答 1查看 264关注 0票数 1

我有一个WCF服务,它为不同的WCF服务提供身份验证/授权。

下面是一个示例方法:

代码语言:javascript
复制
 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正确标识远程端点。

服务的服务器绑定如下所示:

代码语言:javascript
复制
 <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>

客户方:

代码语言:javascript
复制
<client>
  <endpoint address="[site location]/AccountManagement.svc"
    binding="wsHttpBinding" 
    contract="IAccountManagement" name="WSHttpBinding_IAccountManagement">
  </endpoint>
</client>

这两个服务位于同一台服务器上。如果另一个服务有<security mode="None">,我不明白为什么会收到这个错误?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-04 19:33:45

当您试图通过wsHttpBinding使用安全绑定时,您将需要通过https连接到服务器,并使用调试代码允许允许连接到测试服务器。

这是因为您将只有一个自签名证书,而且https在安全证书方面非常严格。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18621510

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档