In an answer to another question it was mentioned that passing XML as a string parameter to a web service was bad practice. What is the reason for this?
This question is at least in part due to a comment of mine about string parameters containing XML being bad practice in web service design. Here's why:
If the web service author wanted his service to accept XML, with or without a schema, then he should have defined the parameter as being of the XML Schema type <xs:any/>. That permits an arbitrary XML element. It's possible to restrict the permitted XML by using <xs:any namespace="xml namespace" processContents="strict" />. This will restrict the XML to being from the particular namespace, and will validate the XML against schemas. The recipient of such a message will be able to process it as pure XML, or possibly as type object or XmlElement or the platform equivalent.
In contrast, if XML is passed as a string, then the recipient has to take action to turn it back into XML. This assumes that actual XML has been properly encoded into the string.
Passing a string also loses you the benefits of XML. For example, the encoded XML cannot be easily processed by XML-based tools, such as XSLT.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With