[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [xmlblaster] is there an example showing how to send an XML document via pub/sub system?

Marcel Ruff wrote:
Hi Gautam,

an XML is a byte[]. If you do a

       byte[] bytes = ...
       try {
           String xml = new String(bytes, "UTF-8");
       } catch (UnsupportedEncodingException e) {

you have assumed it is UTF-8 encoded (which is the xml default and is advisable).

But usually you shouldn't do that.
If you use a xml parser for the XML InputStream (from byte[])
it correctly detects the encoding of the xml by looking at the XML header

 <?xml version="1.0" encoding="UTF-8"?>

To summarize: A byte[] is a perfect transport medium for xml,

Hi Marcel:

Many thanks for this clarification. Makes sense. However, this brings me to another (possibly very naive) question. *IF* one is passing around byte [] as message contents, what would be criteria that might make one decide if the protocol to be used should be socket, or xmlrpc, or CORBA, or RMI? Are firewall/security considerations the primary drivers or is it something else?




Gautam Thaker schrieb:

I am learning more about xmlBlaster by trying various demo programs and running small variations there off. I have run most of the "HelloWorldx.java" pgms and a few others. What I have found so far is that in all cases the content of the user information being sent is a byte array. The key and qos info are in XML, but the user payload is byte array. What I wish to do is to have my payload be a large XML document. (The receiver would have a schema against which it may check for validity before accepting/processing the message.)

Is there an example that shows how this is done? Or is it that in all cases the message content is byte array and all XML documents are simply byte arrays any way? (I am not an XML guru myself, sorry if this is a naive question over all.)