我有以下场景:项目A包含两个接口A和B,以及两个服务端点EndpointA和EndpointB,每个都实现匹配的接口。我有一个单元测试项目,它使用Cassinini来测试服务。我使用使用svcutil生成的代理在我的单元测试中创建客户端对象。下面是我来自单元测试项目的app.config:
<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是否一致。
发生什么事了呢?谢谢。
发布于 2011-04-14 17:38:13
卡西尼号几乎从来不听80口的声音。您需要查找端口Cassini侦听并将其修复(使用项目属性/web并将默认值更改为固定端口号)并更新端点:
<endpoint address="http://localhost:<PORTNUMBER>/MyServiceB.svc/MyService"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IModification"
contract="IModification" name="BasicHttpBinding_IModification" />https://stackoverflow.com/questions/5667199
复制相似问题