0

Visual Studio 2012 を使用して、「サービス参照の追加」を使用して WCF クライアントをクラス プロジェクトに追加しています。しかし、よく知られたエラーが発生しています。

Could not find default endpoint element that references contract ‘Service1.IService1′ in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.

(1) svcutil.exe を介して Service1.cs と output.config を作成します。(2) サービス参照を追加します。参照名前空間を「MyFirstWcfWebServiceReference」として指定します。(3) 既存の Service1.cs ファイルをプロジェクトに追加します。(4) app.config で「MyFirstWcfWebServiceReference」を削除し、コントラクトに IService1 のみを保持します。 (6) プロジェクトをビルドします。

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
    </configSections>
      <system.serviceModel>
        <bindings>
          <basicHttpBinding>
            <binding name="WCFServiceBinding" />
          </basicHttpBinding>
        </bindings>
        <client>
          <endpoint address="http://localhost/webiste/WebService.svc"
            binding="basicHttpBinding" bindingConfiguration="WCFServiceBinding"
            contract="IService1" name="WCFServiceBinding" />
        </client>
      </system.serviceModel>
</configuration>
4

0 に答える 0