This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I hava rpc encoded style web service that returns a string as response. In the string I'll storing a xml file which has CDATA sections and some inline DTD. My problem is sometimes I am getting an error from axis serialization classes saying that there is an invalid character in xml.
So is it better to convert the xml data into a BASE64 string (may be using AXIS API Or Jakarta Commons API) and return that string as response ? or is there any other way of returning xml files as strings ?
In essence, consider escaping (encoding) the offending characters in the text and stop using CDATA sections altogether. This of course means that you will have to decode the content on the other end.
Joined: Sep 17, 2001
That is a nice explanation. I dont have any CDATA sections in my XML. I am wondering are there any best practices of sending xml file in SOAP messages?
Joined: Aug 19, 2005
Originally posted by RR Kumaran: I dont have any CDATA sections in my XML.
Originally posted by RR Kumaran: a xml file which has CDATA sections and some inline DTD
Data Type Definition language isn't XML. So by definition a well-formed XML document (SOAP envelope) cannot contain an inline DTD unless the inline DTD is encoded/escaped (this is why XML schema was created).
Originally posted by RR Kumaran: I am wondering are there any best practices of sending xml file in SOAP messages?
You may be interested in 3.7 Handling XML Documents in a Web Service If you are exchanging XML documents you may want to consider using a document-style Web service instead of an RPC-style web service. Patterns and Strategies for Building Document-Based Web Services [ June 27, 2006: Message edited by: Peer Reynders ]
Joined: Sep 17, 2001
You have given me the correct answers. Thank you for all the links.