WCF Soap Message Remove 'To' Header

Although there are other questions on this subject, none really cover this exact problem. I rarely ask questions because I can usually find the answer.

We are using a WCF client to talk to a Java web service that uses Soap 1.1. I had to create a custom WseHttpBinding to add a userNameToken. The problem is that when the request is serialized, a bunch of header elements are added that the Java service hates. These are specifically:

Action MessageID ReplyTo To

The actual header looks like this:

 <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
 <a:Action s:mustUnderstand="1"/>
 <a:To s:mustUnderstand="1">https://xxx.xxx.xxx</a:To>


After researching my options, I couldn't find a way to remove those without writing a custom encoder or manipulating the message before it was sent. I chose the latter.

Using a custom behavior, I used the IClientMessageInspector to implement a messageInspector class. In the BeforeSendRequest method, I used the following:

message.Headers.RemoveAll("Action", "http://schemas.xmlsoap.org/ws/2004/08/addressing");
message.Headers.RemoveAll("ReplyTo", "http://schemas.xmlsoap.org/ws/2004/08/addressing");
message.Headers.RemoveAll("To", "http://schemas.xmlsoap.org/ws/2004/08/addressing");

I was quite surprised that it removed all of the headers exception for one. Here is the result:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<a:To s:mustUnderstand="1">https://pilot.eidverifier.com/uru/soap/ut/usv3</a:To>

As you can see, the 'To' element is still there. So, my question is why? Does it require that to send the message?

I can't help but feel that I'm approaching this the wrong way. Is there a way to make mustUnderstand false? Is there a property setting that removes all of the extra elements? I'm in release mode.

Any help or direction is appreciated.


You are using the wrong messageVersion,

to remove, Use Soap11 instead of Soap11WSAddressing10

Need Your Help

Get Host's IP Address and HTTP Status, following redirects

php ssh http-status-codes

I'm building a little web app that will ping an array of domains and return their status, letting me monitor if they're up or down, pointing to the right servers, etc. (live example that may or may...

'Make' command not found (associated with Less)

ruby-on-rails-3 node.js makefile less

I Installed Nodejs, then installed the LESS command line compiler.