C# Generated SOAP Client Custom Converter

Viewed 81

We have a generated client endpoint for a SOAP webservice. Since the web service doesn't have any predefined error messages for the xml when an error occurs the error message is just slapped before the xml and that throws an exception while parsing the response.

Is there any possible way to manipulate the response so we can actually read the message and throw a custom exception for the error message.

1 Answers

In WCF you can use the ambient OperationContext.Current instance.

var context = OperationContext.Current;

var header = new MessageHeader<string>("test");

context.OutgoingMessageHeaders.Add(header.GetUntypedHeader(typeof(string).Name, typeof(string).Namespace));

If you can't use WCF check out the generated SOAP XML and tug it in manually in your program.

Related