DLL で参照される WCF サービスをコーディングしました。そのサービス参照を追加した後、必要なデータで app.config が自動的に生成されました。
クライアントはdllを使用してwcfサービスと通信しています...特別なことは何もありません。しかし、サービス参照のオブジェクトを作成しようとすると、エンドポイント アドレスが見つからないと言ってクラッシュします。
私はグーグルで検索し、バインディングとアドレスをサービス参照に渡すことで修正しました:
readonly BasicHttpBinding _binding = new BasicHttpBinding();
readonly EndpointAddress _address = new EndpointAddress("http://localhost:50309/CustomerService.svc");
using (CustomerServiceClient client = new CustomerServiceClient(_binding, _address))
{
return client.GetActions(customerNumber);
}
これらのデータが自動的に生成されたapp.configに既にあるのに、なぜこれらのパラメーターを渡す必要があるのか 疑問に思っています。app.config の内容を削除しました...それらのデータはどこにも使用されていないようです。
私は何か間違ったことをしていますか?
編集:
dll プロジェクトのアプリ構成:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ICustomerService" 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:50309/CustomerService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICustomerService"
contract="ServiceReference.ICustomerService" name="BasicHttpBinding_ICustomerService" />
</client>
</system.serviceModel>
</configuration>