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 테스트 클라이언트는 웹 기반 엔드 포인트에 유용하지 않습니다. WCF가 다음 버전을 선적 할 때 웹 스타일 엔드 포인트를 표현하기위한 표준이 나타나면 테스트 클라이언트를 지원하여 지원할 수 있지만 현재는 널리 채택되지 않았습니다.
다른 팁
구성이 잘못되었다고 생각합니다. 노드 보안 모드 = "없음"및 속성 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>
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