Sunday, October 9, 2016

The message with Action 'xxx' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher.


Below is the fault message returned when WCF service was invoked with faultCode as ActionNotSupported

<s:Fault xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><faultcode xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a:ActionNotSupported</faultcode><faultstring xml:lang="en-US">The message with Action '&lt;BtsActionMapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
  &lt;Operation Name="Add" Action="http://tempuri.org/ICalculator/Add" /&gt;
&lt;/BtsActionMapping&gt;' 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).</faultstring></s:Fault>



Why it happened


When we consume a WCF service using BizTalk WCF Service Consuming wizard few artifacts are generated like XSD's, Orchestration and couple of Binding files.This binding files actually contains configuration pertaining to port, one of them is generated based on metadata obtained from the service consumed and the other has configurations using WCF Custom Adapter which is for you to customize if there is a need.

In order to invoke a method of a service we have to set Soap Action Header on Send Port.This tells which method to call (Add) which is defined by  ServiceContract Interface (ICalculator) under following ServiceContract Namespace(http://tempuri.org/) service  using through this port.


                    http://tempuri.org/ICalculator/Add

If there is only one method to be invoked then simply providing the Action works.But in case there are multiple actions to be invoked using same port then BtsActionMapping is used. (It can be used for single action too)


<BtsActionMapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Operation Name="Operation_Add" Action="http://tempuri.org/ICalculator/Add" />
  <Operation Name="Operation_Subtract" Action="http://tempuri.org/ICalculator/Subtract" />
  <Operation Name="Operation_Divide" Action="http://tempuri.org/ICalculator/Divide" />
</BtsActionMapping>

Where Operation Name should be the name of operation specified in Logical Port which is binded to this physical port.

You can manually create the send port and configure it accordingly, but binding files are already generated -- so I imported it directly and send port was created with SOAP Action header as can be seen.
 

After importing ,starting the application and while testing got fault message back and as it says their was mismatch in the Action. As can be seen in image below, Operation name is Operation_Add but as seen above action mapped is 

Operation Name="Add" Action="http://tempuri.org/ICalculator/Add"








What to do

Operation Name which is mapped in SOAP Action header should be the name of operation specified in Logical Port which is binded to this physical port




No comments:

Post a Comment