IT박스

EndpointDispatcher 예외에서 ContractFilter 불일치

itboxs 2020. 8. 7. 08:10
반응형

EndpointDispatcher 예외에서 ContractFilter 불일치


테스트하려는 다음 시나리오가 있습니다.

  1. 일반적인 WSDL
  2. WSDL을 기반으로 개체를 구현하고 IIS에서 호스팅되는 WCF 끝점입니다.
  3. WSDL을 기반으로 프록시를 사용하여 요청을 생성하는 클라이언트 앱입니다.

클라이언트에서 서비스 엔드 포인트로 웹 서비스 호출을 할 때 다음 예외가 발생합니다.

{ " EndpointDispatcher의 ContractFilter 불일치로 인해 ' http : // IMyService / CreateContainer ' 작업이있는 메시지를 수신자에서 처리 할 수 ​​없습니다. 이는 계약 불일치 (발신자와 수신자 간의 작업 불일치) 또는 보낸 사람과받는 사람 간의 바인딩 / 보안 불일치. 보낸 사람과받는 사람이 동일한 계약과 동일한 바인딩을 갖고 있는지 확인하십시오 (보안 요구 사항, 예 : 메시지, 전송, 없음). "}

MS Service Trace Viewer를 사용하기 시작했지만 어디를 봐야할지 모르겠습니다. 클라이언트와 엔드 포인트의 클래스를 보면 동일하게 보입니다.

이 문제를 어떻게 디버깅하기 시작합니까?

이 예외의 가능한 원인은 무엇입니까?


"EndpointDispatcher에서 ContractFilter 불일치"는 수신자가 메시지를 수신 한 엔드 포인트에 대해 구성한 계약과 일치하지 않기 때문에 수신자가 메시지를 처리 ​​할 수 ​​없음을 의미합니다.

그 이유는 다음과 같습니다.

  • 클라이언트와 발신자간에 서로 다른 계약이 있습니다.
  • 클라이언트와 발신자간에 다른 바인딩을 사용하고 있습니다.
  • 클라이언트와 보낸 사람간에 메시지 보안 설정이 일치하지 않습니다.

EndpointDispatcher주제에 대한 자세한 내용 수업을 참조하십시오.

그래서:

클라이언트와 서버 계약이 일치하는지 확인하십시오.

  • WSDL에서 클라이언트를 생성 한 경우 WSDL이 최신입니까?
  • 최근 계약을 변경 한 경우 클라이언트와 서버의 올바른 버전을 배포 했습니까?
  • 클라이언트 계약 클래스를 직접 만든 경우 네임 스페이스, 요소 이름 및 작업 이름이 서버에서 예상하는 이름과 일치하는지 확인합니다.

바인딩이 클라이언트와 서버간에 동일한 지 확인하십시오.

  • .config 파일을 사용하여 엔드 포인트를 관리하는 경우 바인딩 요소가 일치하는지 확인하십시오.

보안 설정이 클라이언트와 서버간에 동일한 지 확인하십시오.

  • .config 파일을 사용하여 엔드 포인트를 관리하는 경우 보안 요소가 일치하는지 확인하십시오.

이 오류가 발생했으며 수신자 계약이 호출되는 메서드를 구현하지 않아서 발생했습니다. 기본적으로 누군가가 최신 버전의 WCF 서비스를 호스트 서버에 배포하지 않았습니다.


이 문제가 발생하여 다른 서비스에서 복사 한 프록시 생성기에서 서비스 이름을 변경하는 것을 잊었습니다.

나는 이것을 바꿨다 ...

Return New Service1DataClient(binding, New EndpointAddress(My.Settings.WCFServiceURL & "/Service1Data.svc"))

에...

Return New Service2DataClient(binding, New EndpointAddress(My.Settings.WCFServiceURL & "/Service2Data.svc"))

단순한 코드 오류 였지만 디버깅이 거의 불가능했습니다. 나는 이것이 누군가의 시간을 절약하기를 바랍니다.


잘못된 URL 에 연결하려고하면이 메시지가 표시됩니다 .)

내 시스템에 비슷한 이름으로 정의 된 두 개의 엔드 포인트와 서비스가 있습니다.

내 클라이언트에서 URL이 어느 시점에서 바뀌었을 때이 정확한 오류가 발생했습니다. 이 멍청한 실수를 마침내 알아낼 때까지 머리를 긁었습니다.


내 계약 구현에 다음을 추가하여이 문제를 해결했습니다.

[ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]

예를 들면 다음과 같습니다.

[ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]
public class MyUploadService : IMyUploadService
{

}

.net 엔드 포인트를 호출하는 Java 클라이언트의 경우. 이는 Soap Action 헤더가 일치하지 않아 발생했습니다.

Content-Type: application/soap+xml;charset=UTF-8;action="http://example.org/ExampleWS/exampleMethod"

위의 HTTP 헤더 또는 다음 XML 태그는 호출하려는 작업 / 메소드와 일치해야합니다.

   <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/" xmlns:gen="http://schemas.datacontract.org/2004/07/GenesysOnline.WCFServices">
   <soap:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
      <wsa:To>https://example.org/v1/Service.svc</wsa:To>
      <wsa:Action>http://example.org/ExampleWS/exampleMethod</wsa:Action>
   </soap:Header>
   <soap:Body>
    ...
   </soap:Body>
</soap:Envelope>

svc 파일을 복사하고 이름을 바꾼 후에 이것을 얻었습니다. 파일 이름과 svc.cs 파일의 이름이 올바르게 변경되었지만 마크 업은 여전히 ​​원본 파일을 참조했습니다.

To fix this, right click on the copied svc file and choose View Markup and change the service reference.


As mentioned in other answers, such as @chinto, this happens when the SOAP:Action header element does not match the Endpoint.

You can find the correct URI to use by looking at the server's WSDL. You will see an operation element with an input child that has an "Action" attribute. That is what your SOAP:Action needs to be on the client request.

<wsdl:operation name="MethodName">
<wsdl:input wsaw:Action="http://tempuri.org/IInterface/MethodName" message="tns:IInterface_MethodName_InputMessage"/>
<wsdl:output wsaw:Action="http://tempuri.org/IInterface/MethodNameResponse" message="tns:IInterface_MethodName_OutputMessage"/>
</wsdl:operation>

I had the same issue. The problem was that I copied the code from another service as a starting point and did not change the service class in .svc file

Open the .svc file an make sure that the Service attribute is correct.

 <%@ ServiceHost Language="C#" Debug="true" Service="SME.WCF.ApplicationServices.ReportRenderer" CodeBehind="ReportRenderer.svc.cs" %>

The error says that there is a mismatch, assuming that you have a common contract based on the same WSDL, then the mismatch is in the configuration.

For example that the client is using nettcpip and the server is set up to use basic http.


I had a similar error. This could be because you would have changed some contract setting on your config file after it was refrenced into you project. solution - Update the webservice reference on you VSstudio project or create a new proxy using svcutil.exe


I spent days looking for the answer and I found it, but not in this thread. I am very new to WCF and C#, so to some the answer might be obvious.

In my situation I had a client tool that was originally developed for ASMX service, and for me it was returning that same error message.

After trying all sorts of recommendations I found this site:

http://myshittycode.com/2013/10/01/the-message-with-action-cannot-be-processed-at-the-receiver-due-to-a-contractfilter-mismatch-at-the-endpointdispatcher/

It put me on the right path. Specifically "soap:operation" - WCF was appending ServiceName to the Namespace:

client expected Http://TEST.COM/Login, but WCF sent Http://TEST.COM/IService1/Login. Solution is to add setting to [OperationContract] like this:

[OperationContract(Action = "http://TEST.COM/Login", ReplyAction = "http://TEST.COM/Login")] (Ignore blank spaces in Http)


This could be for 2 reasons for this:

  1. service ref is outdated, right click service ref n update it.

  2. contract which you have implemented might be different what client has. Compare both service n client contract n fix the contracts mismatch.


If you are calling WCF method you should include interface in Header.

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(Url);
if (Url.Contains(".svc"))
{
    isWCFService = true;
    req.Headers.Add("SOAPAction", "http://tempuri.org/WCF_INterface/GetAPIKeys");
}
else 
{
    req.Headers.Add("SOAPAction", "\"http://tempuri.org/" + asmxMethodName+ "\"");
}

Also it might be useful for those who are doing this by coding. You need to add WebHttpBehavior() to your added service endpoint. Something like:

restHost.AddServiceEndpoint(typeof(IRestInterface), new WebHttpBinding(), "").Behaviors.Add(new WebHttpBehavior()); 

Take a look at : https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/calling-a-rest-style-service-from-a-wcf-service


Silly, but I forgot to add [OperationContract] to my service interface (the one marked with [ServiceContract]) and then you also get this error.


Your client was not updated.So Update your services from Web service and then rebuild your project


This error generally comes if the code is not deployed properly.

In my case, I have two services ServiceA and ServiceB. I found the problem that ServiceB files were not deployed properly. Because of which when ServiceA was calling ServiceB internally it was giving below error.

**오류**

Please make sure the files and references are deployed properly.


I had this problem as well. It turned out it was caused by the contract serializer on server's end. It couldn't return my data contract object because some of its datamembers were readonly properties.

Make sure your objects have setters for properties meant to be serialized.


Oddly enough we worked around this error by using the same casing the Path and OperationContract name used. Apparently it was case-sensitive. If anyone knows why, please comment. Thank you!


So, my case was the following. I didn't use proxy for the client-server interaction, I used ChannelFactory (thus all the advice to upgrade to service reference was meaningless to me).

The service was hosted in IIS and for some reason it had wrong references in the bin folder there. The project recompilation simply didn't lead to new dlls in that folder.

So I just deleted all the stuff from there and added reference to the service in the same solution, then recompiled and now everything works.


My issue turned out to be something rare, but I'll mention it anyway.

I encountered the issue deploying to our development environment. On that machine, our build person had created two folders (deployed two applications). An old version and the new current version. So if you don't have two versions of your application on the web server, this does not apply to you.

The new location he created had a non-standard name as the first part of the url after the host:

net.tcp://dev.umbrellacorp.com/DifferentFolderName/MyProvider

On my local machine, my client was pointing to the standard folder name as was set up on all environments (except development), including my local environment.

net.tcp://dev.umbrellacorp.com/AppServices/MyProvider

When I blew away and replaced the web.config on development with my local copy, the part of the url that needed to be special was blown away with the standard part, so as a result the client on dev pointed to the old application.

The old application had an old contract and didn't understand the request and threw this error.


I had the same error on a WCF service deployed, the problem was related to another service deployed with another contract with the same port.

Solution

I used different ports in the web.config and the issue disappeared.

Service 1

contract="Service.WCF.Contracts.IBusiness1" 
baseAddress="net.tcp://local:5244/ServiceBusiness" 

Service 2

contract="Service.WCF.Contracts.IBusiness2"
baseAddress="net.tcp://local:5243/ServiceBusiness"

Also, I ran into this situation by using diferent port for the same address between the service and the consumer.


내 서버의 GAC에 이전 버전의 DLL이 있기 때문에이 오류가 발생했습니다. 따라서 모든 것이 올바르게 참조되고 어셈블리 / GAC가 좋은 dll로 최신 상태인지 확인하십시오.


동일한 앱 풀에서 동일한 wcf의 두 복사본을 실행했기 때문에 테스트 서버 에서이 문제가 발생했습니다. 나를 위해 해결 된 것은 내 wcf에서 각 버전에 대해 별도의 풀을 만들고 그 후에 IIS를 다시 시작하는 것입니다.


와 NodeJS를 사용하는 사람들을 위해 Axios의이 는 SOAP 요청을 만들기 위해 당신이 포함되어야합니다 SOAPAction header. 아래 예를 확인하십시오.

axios.post('https://wscredhomosocinalparceria.facilinformatica.com.br/WCF/Soap/Emprestimo.svc?wsdl',
           xmls,
  {headers:
  {
    'Content-Type': 'text/xml',
    SOAPAction: 'http://schemas.facilinformatica.com.br/Facil.Credito.WsCred/IEmprestimo/CalcularPrevisaoDeParcelas'}
  }).then(res => {
    console.log(res)
  }).catch(err => {
    console.log(err.response.data)
  })

참고 URL : https://stackoverflow.com/questions/5487791/contractfilter-mismatch-at-the-endpointdispatcher-exception

반응형