What is the best way to publish a document/literal XML message definition within a Web Services Description Language (WSDL) file?
Should I define a schema that takes a single xsd:string and have clients pass in an XML document wrapped within a CDATA section for more control over versioning, error handling, etc.? Or should I publish strongly typed User Defined Types in the WSDL that exactly map to the XML message?
In the latter case, the message can be validated by the SOAP engine and client code tools, such as WSDL.EXE or WSDL2JAVA, and can create easy to use clients. Which approach makes the most sense and will keep us compliant with WS-* specifications?
Definitely do not send the message as a string wrapped within a CDATA section. That approach defeats many of the valuable features of using SOAP and WSDL. You should strongly type the messages, and specify the type information using XML Schema, for all the reasons you say and more. For example, without a proper schema, you can't specify which parts of the message you would like to sign or encrypt using WS-Security.
This was first published in June 2005