2009-03-02 14 views
5

WCFサービスで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テストクライアントを使用できないのでしょうか?

答えて

11

私の以前の回答は無視してください。私は問題がクライアント側の設定ではないと思う。

WCF Test Client and WebHttpBindingを参照してください。私はあなたの設定が間違っていると思う

This is a limitation of the web programming model itself. Unlike SOAP endpoints (i.e., those with BasicHttpBinding, WSHttpBinding, etc) which have a way to expose metadata about itself (WSDL or Mex) with information about all the operations/ parameters in the endpoint, there's currently no standard way to expose metadata for a non-SOAP endpoint - and that's exactly what the webHttpBinding-based endpoints are. In short, the WCF Test Client won't be useful for web-based endpoints. If some standard for representing web-style endpoints emerges when WCF ships its next version, we'll likely update the test client to support it, but for now there's none widely adopted.

+0

@ stimpy77、私は単にMSの従業員によってリンクされた答えから引用しました。 WCFでは、バインドは[WebHttpBinding](http://msdn.microsoft.com/en-us/library/system.servicemodel.webhttpbinding.aspx)と呼ばれ、WSDL 2では[HTTPバインディング](http: /www.w3.org/TR/wsdl20-adjuncts/#http-binding)、「ウェブベース」がここで何を意味しているかは、文脈から明らかです。 RESTという用語は、HTTP経由でメソッドを公開するだけではありません。それはリソースとしての扱いとHTTP動詞の使用などです。[Richardson Maturity Model](http://martinfowler.com/articles/richardsonMaturityModel.html)を参照してください。 –

0

は、あなたが= "なし" ノードのセキュリティモードを追加していないし、私の設定など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> 
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 
関連する問題