次のシナリオがあります。プロジェクト A には、2 つのインターフェイス A と B と 2 つのサービス エンドポイント (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 を呼び出すと、次のエラー メッセージが表示されます。
テスト メソッド MyMethod が例外をスローしました: System.ServiceModel.EndpointNotFoundException: To 'http://localhost/MyServiceB.svc/MyServiceB' を含むメッセージは、EndpointDispatcher での AddressFilter の不一致により、受信側で処理できません。送信者と受信者の EndpointAddresses が一致していることを確認してください。
何が起こっていますか?ありがとう。