Saturday Apr 28, 2007
Today's Page Hits: 208
Saturday Apr 28, 2007
At times an XML could contain characters or declarations that are not supported by SOAP or the runtime - examples are, DTD declarations, binary data, locale specific character encoding, etc. In such cases you may have to use Base64 encoding of the raw bytes into the message payload. You have to be aware of the fact that base64 encoding will increase the amount of processing required before transmitting an XML document and again before parsing it at the receiving end. This means once a message is encoded, the recipient must decode the entire message in order to work with any part of it. You just have to also be aware of the fact that both parties need to know out of band what the data is for this approach to work. Another disadvantage is Base64 encoding will increase the message size significantly.
Like this write-up? Subscribe to receive more like it.
Disclaimer: The contents of this Weblog represent my personal opinion which may differ from the official views of my employer, Sun Microsystems, Inc. or any past employers.
Parsing the XML should actually be easier since its dealt with as a single lexical token with no change in parser state.
"both parties need to know out of band what the data is"
And the alternative, MTOM or similar attachment ways do not?
"Base64 encoding will increase the message size significantly"
The overhead of BASE64 is only about +34%, its no more significant that its used constantly by mail/MIME.
While formats, frameworks and specs change constantly, BASE64 simply works. Those are our experiences anyhow.
Posted by Casper on April 28, 2007 at 01:07 PM PDT #
Everything has its use and a place under the Sun. You only talk about parsing the XML being easier, but fail to consider the fact that there is work involved for <span style="font-weight: bold; font-style: italic;">encoding the message before packaging it</span> at the senders end, and then<span style="font-weight: bold; font-style: italic;"> decoding the message before parsing it</span> at the <span style="font-style: italic;">receivers </span>end. You also fail to consider the that both the sender and the receiver have to <span style="font-weight: bold; font-style: italic;">negotiate the schema out of band to process the XML</span> which means it becomes difficult to for a new consumer to write a client for the service since the service interface is not well-defined. There are also <a href="http://blogs.sun.com/gopalan/entry/jbi_soa_tips_beware_of">SOAP verbosity issues that you need to take into account when you base64 encode the message, which is why my next SOA tip for today (see <a href="http://blogs.sun.com/gopalan/entry/jbi_soa_tips_beware_of">http://blogs.sun.com/gopalan/entry/jbi_soa_tips_beware_of). I would suggest that for large messages you should consider using MTOM.
Cheers
Gopalan.
Posted by Gopalan Suresh Raj on April 29, 2007 at 10:58 PM PDT #