XML and streaming from/to Tigase
Submitted by taroza on Thu, 2008-05-08 14:12.
Reading RFC3920 for XMPP I realized that the communication c2s is not really done using pure XML:
1. Client sends start of the stream: <stream>
2. ....communication....
3. Client sends end of the stream: </stream>
This means that the client, reading a packet will have to parse a string, instead of parsing XML. Or am I getting something wrong?
However, I hope that when the communication is established and two entities are exchanging data, they are actually exchanging XML (stanzas). Is that right?
Before looking at XMPP I always thought that it works similarly to Web services, i.e. exchanging well-formed XML messages.
Could anyone clarify these concerns a bit. Thanks.
Evaldas
Trackback URL for this post:
http://www.tigase.org/trackback/1386
- Add new comment
- 281 reads






Yes you are absolutely correct here.
Would you like to join Tigase project? :-)
Yes, it really looks like it's a big well-formed XML document... But technically you need some kind of a streaming parser to be able to parse such a fancy non-ending XML document :)
Anyway. Can we say (is it according to XMPP) that only first packets will be non-XML? I mean the first thing a client receives from server is
<stream>....; are the subsequent packets well-formed XML snippets? Meaning that whenever stream has started, every subsequent communication will be ... or , etc.?
All this XMPP stuff is really challenging:)
Evaldas
Well, you are right and you are not right ;-)
In simple words: The whole communication between the XMPP client and the XMPP server is like one huge XML document. The root element is <stream> while all stanzas are child elements of the root element.
So in theory the client and the server exchange well formed XML document (stream). And actually it is also very similar to web services although it doesn't look like this at first look. This is because there is one fundamental difference between web services and XMPP protocol:
Web services normally establish short-term connection between entities, exchange data and close the connection. Normally during the connection life exchanged data form correct XML document and so more important communication is synchronous - one side sends request and then waits for a response.
If you look at XMPP you could see it as a very long-term living web service with connection lasting for hours or days and during the connection life the exchanged data form correct XML document BUT the communication is asynchronous which means at any given time there might be a packet arriving at both ends.
There is one issue however which destroys the well-formed XML stream in the XMPP protocol - stream restarts. As far as I know XSF works now on removing stream restarts from the protocol.