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

WCF - EndpointNotFoundException
EN

Stack Overflow用户
提问于 2011-04-14 17:32:15
回答 1查看 2.4K关注 0票数 0

我有以下场景:项目A包含两个接口A和B,以及两个服务端点EndpointA和EndpointB,每个都实现匹配的接口。我有一个单元测试项目,它使用Cassinini来测试服务。我使用使用svcutil生成的代理在我的单元测试中创建客户端对象。下面是我来自单元测试项目的app.config:

代码语言:javascript
复制
<system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding name="basicHttp" closeTimeout="00:10:00" openTimeout="00:10:00"
      receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false"
      bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
      maxBufferSize="5242880" maxBufferPoolSize="524288" maxReceivedMessageSize="5242880"
      messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
      useDefaultWebProxy="true">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
        maxBytesPerRead="4096" maxNameTableCharCount="5242880" />
      <security mode="None">
        <transport clientCredentialType="None" proxyCredentialType="None"
          realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />
      </security>
    </binding>
    <binding name="BasicHttpBinding_IAdministration" closeTimeout="00:01:00"
                        openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                        allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                        maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                        messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                        useDefaultWebProxy="true">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
          maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      <security mode="None">
        <transport clientCredentialType="None" proxyCredentialType="None"
            realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />
      </security>
    </binding>
    <binding name="BasicHttpBinding_IRetrieval" closeTimeout="00:01:00"
        openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
        allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
        maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
        messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
        useDefaultWebProxy="true">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
          maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      <security mode="None">
        <transport clientCredentialType="None" proxyCredentialType="None"
            realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />
      </security>
    </binding>
    <binding name="BasicHttpBinding_IModification" closeTimeout="00:01:00"
        openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
        allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
        maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
        messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
        useDefaultWebProxy="true">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
          maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      <security mode="None">
        <transport clientCredentialType="None" proxyCredentialType="None"
            realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />
      </security>
    </binding>      
  </basicHttpBinding>
</bindings>
<client>      
  <endpoint address="http://localhost/MyServiceA.svc/MyServiceA"
      binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IRetrieval"
      contract="IRetrieval" name="BasicHttpBinding_IRetrieval" />
  <endpoint address="http://localhost/MyServiceB.svc/MyService"
      binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IModification"
      contract="IModification" name="BasicHttpBinding_IModification" />      
</client>

当我打电话给ServiceA时,它可以正常工作。但是,当我调用ServiceB时,会收到以下错误消息:

System.ServiceModel.EndpointNotFoundException:

测试方法MyMethod抛出异常:由于AddressFilter在EndpointDispatcher上不匹配,无法在接收端处理带有To 'http://localhost/MyServiceB.svc/MyServiceB‘的消息。检查发送方和接收方的EndpointAddresses是否一致。

发生什么事了呢?谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-04-14 17:38:13

卡西尼号几乎从来不听80口的声音。您需要查找端口Cassini侦听并将其修复(使用项目属性/web并将默认值更改为固定端口号)并更新端点:

代码语言:javascript
复制
 <endpoint address="http://localhost:<PORTNUMBER>/MyServiceB.svc/MyService"
  binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IModification"
  contract="IModification" name="BasicHttpBinding_IModification" />
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5667199

复制
相关文章

相似问题

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