.Net WCF service with Soap 1.2, no addressing. How to force the SoapAction to be read from a different header node

317 Views Asked by At

We are working with .NET with a 3rd party which has requested that we expose a WCF Endpoint with SOAP 1.2 without addressing. They, however, indicated that it is a custom implementation which they send the Soap Action in a specific soap header XML element and not in the content-type as the specification indicates. I have been trying to manipulate the request on receiving by using Custom Bindings, Endpoint behaviours, IDispatchOperationSelector but nothing is working. I always get the error "The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher." before entering AfterReceiveRequest (IDispatchMessageInspector) or SelectOperation (IDispatchOperationSelector). I would not want to construct the full hosting process and would like to know if there is a way to get the Soap action from a different node and inject it as the addressing soap header or in content-type before it tries to validate that the action exists in the contracts... If this is not enough information please let me know. Thank you in advance.


Update

After some searching and reading I found a workaround:

  1. Added a generic Unactioned contract in the WCF contracts class [System.ServiceModel.OperationContractAttribute(Action = "*", ReplyAction = "*")] and added names to all operations in the service.
  2. Added an additional IEndpointBehavior class with ApplyDispatchBehavior which registers the OperationSelector to a new IDispatchOperationSelector.
  3. Added an IDispatchOperationSelector which gets the action from the custom header and returns it as the operation name.
  4. In the WCF service class implementation added the UnActioned operation with throwing exception as a fallback in case a wrong operation is sent.

Ran into some issues like the Operation name cannot contain ":" but that was simple to discuss with the 3rd party to change.

Hope it helps.

0

There are 0 best solutions below