iis で (ローカルに) ホストされている WCF サービスに ac# クライアントからアクセスしようとすると、次のエラーが発生します。
ServiceModel クライアント構成セクションで、名前が 'X' でコントラクトが 'Contract Name' のエンドポイント要素が見つかりませんでした。これは、アプリケーションの構成ファイルが見つからなかったか、この名前に一致するエンドポイント要素が client 要素に見つからなかったためである可能性があります。
これはクライアントの app.config です (接続をテストするためだけの NUnit フィクスチャです)。
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_MyWs" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://localhost/MyWs/MyWs.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_MyWs"
contract="MyServiceSvc.IMyWs"
name="BasicHttpBinding_MyWs" />
</client>
</system.serviceModel>
</configuration>
ブラウズしたら
https://localhost/MyWs/MyWs.svc?wsdl
サーバー部分が正常に動作しているため、正しい出力が得られます。
さらに、soapUI で自分の ws をテストできるので、問題はクライアント、おそらく app.config にあるはずです。
誰かがそれを見たい場合に備えて、私のクライアントコード:
[TestFixture]
public class MyWsProxyFixture
{
private readonly MyWsClient _client = new MyWsClient();
[Test]
public void ProxyCreation()
{
Assert.IsNotNull(_client);
}
//More tests here
}
さらに面白いことに、まったく同じ構成とクライアントが別のマシンで動作します。はい、そうです。自分でも信じられませんが、そうです。
これを解決するためのヒントや提案をいただけますか?
ありがとう!
PS: クライアントのサービス参照は問題ありません。