5

WCF サービスで WCF テスト クライアントを使用しようとすると、エラーが発生します。サービスコードは次のとおりです。

[ServiceContract]
public interface IEmployeeService
{
    [OperationContract(Name = "GetEmployee")]
    [WebGet(RequestFormat = WebMessageFormat.Xml,
        UriTemplate = "/Employees/{employeeNumber}")]
    Employee GetEmployee(string employeeNumber);
}

public Employee GetEmployee(string employeeNumber)
{
    var employeeNumberValue = Convert.ToInt32(employeeNumber);
    var employee = DataProvider.GetEmployee(employeeNumberValue);
    return employee;
}

<system.serviceModel>
    <services>
        <service name="Employees.Services.EmployeeService"
                 behaviorConfiguration="metaBehavior">
            <endpoint address=""
                      behaviorConfiguration="webHttp"
                      binding="webHttpBinding"
                      contract="Employees.Services.IEmployeeService">
            </endpoint>
            <endpoint address="mex"
                      binding="mexHttpBinding"
                      contract="IMetadataExchange">
            </endpoint>
        </service>
    </services>
    <behaviors>
        <endpointBehaviors>
            <behavior name="webHttp">
                <webHttp/>
            </behavior>
        </endpointBehaviors>
        <serviceBehaviors>
            <behavior name="metaBehavior">
                <serviceMetadata httpGetEnabled="true" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
</system.serviceModel>

WCF テスト クライアントを使用してサービスに接続できますが、GetEmployee(employeeNumber) を呼び出そうとすると、次のエラーが発生します。

サービスの呼び出しに失敗しました。考えられる原因: サービスがオフラインであるか、アクセスできません。クライアント側の構成がプロキシと一致しません。既存のプロキシは無効です。詳細については、スタック トレースを参照してください。新しいプロキシを開始するか、デフォルト構成に復元するか、サービスを更新することで、回復を試みることができます。

ブラウザからリクエストを送信することで、このサービスを正常に呼び出すことができました。

WCF テスト クライアントを使用できない理由を教えてください。

4

3 に答える 3

11

私の以前の回答は無視してください。問題はクライアント側の設定にあるとは思いません。

WCF テスト クライアントと WebHttpBindingを参照してください。

これは、Web プログラミング モデル自体の制限です。SOAP エンドポイント (つまり、BasicHttpBinding、WSHttpBinding などを持つエンドポイント) は、エンドポイント内のすべての操作/パラメーターに関する情報を使用して、それ自体 (WSDL または Mex) に関するメタデータを公開する方法を持っていますが、現在、エンドポイントのメタデータを公開する標準的な方法はありません。非 SOAP エンドポイント - それがまさに webHttpBinding ベースのエンドポイントです。つまり、WCF テスト クライアントは Web ベースのエンドポイントには役に立ちません。WCF が次のバージョンを出荷するときに、Web スタイルのエンドポイントを表すための何らかの標準が出現した場合、それをサポートするためにテスト クライアントを更新する可能性がありますが、今のところ広く採用されているものはありません。

于 2009-03-04T07:52:45.640 に答える
0

あなたの設定が間違っていると思います。node security mode="None" と属性 bindingConfiguration="NoneSecurity" を追加する必要があります

私の設定として変更し、再試行してください:

<system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="NoneSecurity"
          maxBufferPoolSize="12000000" maxReceivedMessageSize="12000000" useDefaultWebProxy="false">
          <readerQuotas maxStringContentLength="12000000" maxArrayLength="12000000"/>
          <security mode="None"/>
        </binding>
      </wsHttpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="Elong.GlobalHotel.Host.IHotelAPIBehavior"
        name="Elong.GlobalHotel.Host.IHotelAPI">
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="NoneSecurity" contract="Elong.GlobalHotel.Host.IIHotelAPI">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="Elong.GlobalHotel.Host.IHotelAPIBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
于 2012-11-29T05:17:25.457 に答える
0
  I had a similar problem, the solution was in a minor error in the message alias ... that very generic message ... in our case was assigned a Boolean false if the right is true.
  This value was in the MDM application that was running on websphere.

私の場合のパス:

   /opt/infamdm/hub/server/resources/cmxserver.properties
   /opt/infamdm/hub/cleanse/resources/cmxcleanse.properties
于 2014-10-30T09:09:19.900 に答える