Java – The message with Action ” cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher

javasoapspring

Getting this error message when invoking a web service:-

org.springframework.ws.soap.client.SoapFaultClientException: The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).

Best Answer

You forgot to specify the SOAP action before invoking the web service. Open your WSDL file and search the operation you are trying to invoke. You should see something like this:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions ...>
...
<wsdl:binding ...>
    ...
    <wsdl:operation name="OhMyGawd">
        <soap:operation soapAction="http://oh.my.gawd"/>
        ...
    </wsdl:operation>
</wsdl:binding>
...

Take note of the soapAction value, in this example, it is http://oh.my.gawd.

If you are using Spring Web Services, add the following lines:

@Autowired
private WebServiceTemplate webServiceTemplate;

public void run() {
   ObjectFactory objectFactory = new ObjectFactory();

   // Create the request payload
   OhMyGawd ohMyGawd = objectFactory.createOhMyGawd();
   ohMyGawd.setValue(...);

   OhMyGawdResponse response = (OhMyGawdResponse) webServiceTemplate.marshalSendAndReceive(
        ohMyGawd, 
        new SoapActionCallback("http://oh.my.gawd")
);

...

}

NB: Credits to this site https://myshittycode.come

Related Topic