Is there a way to prevent .NET from automatically XML-encoding a web service input string?

Viewed 20

I'm writing some VB.NET code to call a third-party SOAP service which I have no control over. Unfortunately, the web service method that I am calling is designed to take a "payload" string which needs to be string of XML wrapped in a CDATA block. I personally think this design is crazy but I have to work with it. I've created the proxy classes in Visual Studio using the service's WSDL. The problem is that whatever I pass to the service method is getting XML-encoded by .NET to replace the "<" characters with "&lt;", etc. This encoding extends to the CDATA tags themselves. This is causing the request to fail on the web service end.

Just to give an example, here is a (drastically simplified) sample of the SOAP envelope I'm trying to generate:

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
    <s:Body>
        <LookupBusiness>
            <inputPayload>
                <![CDATA[<?xml version="1.0" encoding="utf-8"?><Company>ACME</Company>]]>
            </inputPayload>
        </LookupBusiness>
    </s:Body>
</s:Envelope>

The only part I'm passing in is the part between the <inputPayload> tags.

It is being transformed into something like this:

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
    <s:Body>
        <LookupBusiness>
            <inputPayload>
                &lt;![CDATA[&lt;?xml version="1.0" encoding="utf-8"?&gt;&lt;Company&gt;ACME&lt;/Company&gt;]]&gt;
            </inputPayload>
        </LookupBusiness>
    </s:Body>
</s:Envelope>

Is there some way to prevent .NET from doing this encoding?

0 Answers
Related