4

異なるバインディングを持つ 3 つのエンドポイントを提供しようとしている Web サービスを作成しました。1.basicHttpBinding、2.wsHttpBinding、3.webHttpBinding

サービス参照を作成すると、basicHttpBinding および wsHttpBinding バインディングが作成されたエンドポイントのみが取得されます。webHttpBinding が取得できません。何が間違っている可能性があります。

web.config の serviceModel ノードの構造を次に示します。

  <system.serviceModel>
<diagnostics>
  <messageLogging logEntireMessage="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true"/>
</diagnostics>
<services>
  <service behaviorConfiguration="VersionTolerance.Service1Behavior" name="BookShop.BookShopService">
    <endpoint address="sadha" binding="basicHttpBinding" contract="BookShop.IBookShopService" />
    <endpoint address="ws" binding="wsHttpBinding" contract="BookShop.IBookShopService" >
    </endpoint>
    <endpoint address="web" binding="webHttpBinding" behaviorConfiguration="webHttpBehavior"
      contract="BookShop.IBookShopService" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:49654/" />
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="VersionTolerance.Service1Behavior">
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="true"/>
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="false"/>          
    </behavior>
  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="webHttpBehavior">
      <webHttp/>
    </behavior>
  </endpointBehaviors>
</behaviors>

4

1 に答える 1

10

何も悪いことはありません - それはまさにそれが機能する方法です!

basicHttpBindingまたwsHttpBinding、サービスに関するメタデータを公開する SOAP バインディングです。Visual StudioAdd Service Referenceは、エンドポイントを調べて、エンドポイントの名前、提供するメソッド、パラメーターとして期待するデータ型、および返すものを見つけることができます。

webHttpBindingは REST です。デフォルトでは、REST にはメタデータの概念がありません。サービスの説明やメソッドのリストなどは取得できません。REST はすべてリソースに関するものであり、メソッドではありません。

したがって、 を実行する Add Service Referenceと、SOAP エンドポイントのプロキシ クライアントが取得されますが、REST /エンドポイントのプロキシ クライアントは取得されませんwebHttpBinding。設計どおりに動作します。

REST の上に構築された WCF Data Services は、SOAP バインディングと同様のエクスペリエンスを提供します。Add Service Referenceこれは、OData プロトコルが上でメタデータ交換を定義するため、適切なクライアント側プロキシを実行および取得できるという点です。 RESTの。したがって、REST サービスを WCF データ サービスに変えることができれば、問題はありません。

それ以外の場合、REST では、REST サービスのリソース URI と、REST コンテキストでの HTTP 動詞の動作を (ドキュメント ページなどから) 「知る」必要があります。

于 2011-01-19T05:59:44.410 に答える