Home > Software engineering >  Adding transaction ID to SOAP header for detecting repeated calls
Adding transaction ID to SOAP header for detecting repeated calls

Time:11-22

My .NET application needs to connect to an external SOAP service. I let Visual Studio generate the client based on the WSDL description.

The service allows retrying for failed requests, but needs a transaction ID in the soap header in order to detect the repeated calls.

I was able to add the transaction ID by creating a GUID in an IClientMessageInspector. And my plan was to use Polly for retrying.

My problem is: Polly knows nothing about the IClientMessageInspector, and the inspector doesn't know if the request is a retry.

Is there a way to pass that information along, or is there an alternative way of changing the SOAP header? Can Visual Studio be configured to do that?

CodePudding user response:

Found the solution here:

Instead of using IClientMessageInspector, SOAP metadata can be accessed via OperationContextScope(client.InnerChannel). For convenience, this can then be wrapped in a custom proactive Polly policy.

  • Related