1

Web サービスを追加しようとしています。

これは私の設定ファイルです

 <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="Service1Soap" 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:51272/Service1.asmx" binding="basicHttpBinding"
        bindingConfiguration="Service1Soap" contract="ServiceReference1.Service1Soap" 
        name="Service1Soap"  />
    </client>
  </system.serviceModel>

これは、Web サービスを呼び出すコントローラーです。

 ServiceReference1.Service1Soap hs = new ServiceReference1.Service1SoapClient();
 int aa = hs.getStockQty(66);

しかし、エラーがあります..

ここに画像の説明を入力

どうすれば解決できますか?? ありがとう。

4

1 に答える 1

2

エンドポイントに複数の参照があると思います。参照を削除して、別の名前で再度追加してください。

そうでない場合、解決策は簡単です。エンドポイント定義をクラス ライブラリの構成ファイルからアプリケーションの構成ファイルにコピーします。

このコントラクト「Service1Soap」の名前空間も確認してください

于 2012-10-24T07:32:46.383 に答える