WCFテストクライアントエラー:サービスの呼び出しに失敗しました
-
03-07-2019 - |
質問
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テストクライアントを使用できない理由は何ですか?
解決
以前の回答は無視してください。問題はクライアント側の設定にあるとは思わない。
WCFテストを参照クライアントとWebHttpBinding 。
これはウェブの制限です プログラミングモデル自体。 SOAPとは異なり エンドポイント(つまり、 BasicHttpBinding、WSHttpBindingなど) メタデータを公開する方法があります 自身について(WSDLまたはMex)と すべての操作に関する情報/ エンドポイントのパラメーターには、 現在公開する標準的な方法はありません 非SOAPエンドポイントのメタデータ-および それはまさに webHttpBindingベースのエンドポイントは次のとおりです。に 要するに、WCFテストクライアントは Webベースのエンドポイントに役立ちます。もし 表現するための標準 WCF時にWebスタイルのエンドポイントが出現する 次のバージョンを出荷します。 テストクライアントを更新してサポートします。 しかし、今のところ広くはありません 採用。
他のヒント
設定が間違っていると思います。ノードセキュリティモード=「なし」を追加する必要があります;および属性bindingConfiguration =&quot; NoneSecurity&quot;
私の設定として変更して、もう一度試してください:
<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>
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