Wednesday, March 26th, 2008

Posting XML as a parameter to a SOAP WebService Method

By Andy Lewisohn

SOAP is an XML-based communication protocol, but you can’t actually pass XML to a SOAP method without a little bit of finessing. The reason for this is straightforward: XML is not a native data type like int, uint, string, etc., and SOAP can be implemented in a number of languages, none of which implement XML in the same way. The ActionScript solution to this problem is simple, but hackish. Wrap the XML document in a CDATA tag and pass the whole thing as a string:

var stringifiedXML:String = "<![CDATA[" + xml.toXMLString() + "]]>"

Now you can pass a stringified XML document to your SOAP service without worrying about special characters.

Leave a Comment