Custom SOAP Headers: WCF and ASMX

Custom SOAP Headers: WCF and ASMX

First the good news, WCF clients should just work with ASMX services that use custom SOAP headers.

Now the not so good news, ASMX clients will work with WCF services that use headers, but the object model is pretty funky. Say you want to do something really crazy like have a header of type string. The ASMX client will represent that header with a class that looks like this:

To use this class, assign a new string array of length 1 to Text and then assign the value of the header to that element and it will work as expected. These sorts of classes will be generated by ASMX for any simple type, the workaround is to use wrapper classes around the headers on the WCF side. This will result in a somewhat clunky OM, but it will make sense.