WCF / SSL错误:无法查找通道以接收传入消息

时间:2014-11-21 22:11:24

标签: wcf silverlight ssl

在使用SSL时,我一直很难在Silverlight中使用WCF调用。我已经知道WCF跟踪说端点正在侦听但是当我的代码试图调用它上面的函数时,WCF跟踪会显示错误:

无法查找频道以接收传入消息。找不到端点或SOAP操作。

如果我浏览服务URL我正确获取服务页面,但在代码中调用它总是失败。同样,这只发生在HTTPS上,而不是在我使用HTTP之前。当然,要添加许多配置更改以使用SSL。我应该注意到WCF域服务功能在SSL上运行良好,而不是WCF服务。以下是我的各种配置文件部分

的Web.config

<system.serviceModel>
    <domainServices>
      <endpoints>
        <add name="OData" type="System.ServiceModel.DomainServices.Hosting.ODataEndpointFactory, System.ServiceModel.DomainServices.Hosting.OData, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      </endpoints>
    </domainServices>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <behaviors>
      <endpointBehaviors>
        <behavior>
          <serviceMetadata httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <bindings>
      <basicHttpBinding>
        <binding name="secureHttpBinding" maxReceivedMessageSize="20000" maxBufferSize="20000">
          <security mode="Transport">
            <transport clientCredentialType="None"/>
          </security>
          <readerQuotas maxArrayLength="20000" maxStringContentLength="20000" />
        </binding> 
      </basicHttpBinding>

    </bindings>
    <services>
      <service name="PictureService">
        <endpoint address="https://MyServer/AdvisorDev/PictureService.svc"
                  binding="basicHttpBinding"
                  bindingConfiguration="secureHttpBinding"
                  contract="PictureService.IPictureService"/>

        <endpoint address="mex"
                  binding="mexHttpsBinding"
                  contract="IMetadataExchange" />
      </service>
    </services>
  </system.serviceModel>

ServiceReferences.ClientConfig:

<configuration>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IPictureService" maxBufferSize="2147483647"
          maxReceivedMessageSize="2147483647">
          <security mode="Transport" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="https://MyServer/AdvisorDev/PictureService.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IPictureService"
        contract="PictureService.IPictureService" name="BasicHttpBinding_IPictureService" />
    </client>
  </system.serviceModel>
</configuration>

创建客户端:

PictureService.PictureServiceClient client = new PictureService.PictureServiceClient();

我在使用VS 2012并使用IIS作为我的Web服务器的Dev计算机上运行它。 IIS正在使用自签名证书。当我的网站首次加载时,我会收到“此网站的安全证书存在问题”错误,单击“继续”,其余应用程序再次运行正常,包括使用动态创建的代理的域服务调用。我使用“添加服务引用”为这个失败的WCF服务创建我的代理 我的SSL来源之一是: http://msdn.microsoft.com/en-us/library/hh556232(v=vs.110).aspx

这是我实施的服务: http://www.silverlightshow.net/items/Uploading-and-downloading-images-from-WCF-in-Silverlight.aspx

我对此表示感谢,谢谢。

2 个答案:

答案 0 :(得分:1)

事实证明,此错误是由此服务的web.config中的服务名称和合同属性中的名称空间不正确引起的。

答案 1 :(得分:0)

以防万一其他人也遇到此问题,我收到同样的错误。修复结果是从我的三个类中删除继承。

我的WCF服务返回了一个List<MyObject>和三个继承自“MyObject”类的类。当其中一个继承类包含在列表中时,抛出此错误。

前:

public class MyObject

public class MyObjectTwo : MyObject

...

List<MyObject> returnList;

MyObjectTwo addingThisBreaksTheService = new MyObjectTwo();

returnList.Add(addingThisBreaksTheService);

return returnList; // Exception thrown after this statement