Behind the scenes – How and What XML’s are exchanged by JAXL

Pre-requisite
Though it’s not mandatory but will be helpful if you have given a casual reading to the following RFC’s:

Case Study: Google Talk Server

  • JAXL Sends >>
    1. <!–?xml version=”1.0″?–>
    2. <stream:stream xmlns:stream=“http://etherx.jabber.org/streams” version=“1.0” xmlns=“jabber:client” to=“gmail.com” xml:lang=“en” xmlns:xml=“http://www.w3.org/XML/1998/namespace”></stream:stream>
  • Gtalk Acknowledges With >>
    1. <!–?xml version=”1.0″ encoding=”UTF-8″?–>
    2. <stream:stream from=“gmail.com” id=“981E0522D7363BDF” version=“1.0” xmlns:stream=“http://etherx.jabber.org/streams” xmlns=“jabber:client”>
    3. <stream:features>
    4.   <starttls xmlns=“urn:ietf:params:xml:ns:xmpp-tls”>
    5.     <required>
    6.   </required></starttls>
    7.   <mechanisms xmlns=“urn:ietf:params:xml:ns:xmpp-sasl”>
    8.     <mechanism>X-GOOGLE-TOKEN</mechanism>
    9.   </mechanisms>
    10. </stream:features></stream:stream>
  • JAXL Sends >>
    1. <starttls xmlns=“urn:ietf:params:xml:ns:xmpp-tls”></starttls>
  • Gtalk Acknowledges With >>
    1. <proceed xmlns=“urn:ietf:params:xml:ns:xmpp-tls”></proceed>
  • JAXL Sends >>
    1. <!–?xml version=”1.0″?–>
    2. <stream:stream xmlns:stream=“http://etherx.jabber.org/streams” version=“1.0” xmlns=“jabber:client” to=“gmail.com” xml:lang=“en” xmlns:xml=“http://www.w3.org/XML/1998/namespace”></stream:stream>
  • Gtalk Acknowledges With >>
    1. <!–?xml version=”1.0″ encoding=”UTF-8″?–>
    2. <stream:stream from=“gmail.com” id=“C01610C43D6A37A2” version=“1.0” xmlns:stream=“http://etherx.jabber.org/streams” xmlns=“jabber:client”>
    3. <stream:features>
    4.   <mechanisms xmlns=“urn:ietf:params:xml:ns:xmpp-sasl”>
    5.     <mechanism>PLAIN</mechanism>
    6.     <mechanism>X-GOOGLE-TOKEN</mechanism>
    7.   </mechanisms>
    8. </stream:features></stream:stream>
  • JAXL Sends >>
    1. <auth xmlns=“urn:ietf:params:xml:ns:xmpp-sasl” mechanism=“PLAIN”>AGFjY192nbRbm3J1cGvxYWRzAG15QVRNcGlukT9zcpMxAjI=</auth>
  • Gtalk Acknowledge With >>
    1. <success xmlns=“urn:ietf:params:xml:ns:xmpp-sasl”></success>
  • JAXL Sends >>
    1. <!–?xml version=”1.0″?–>
    2. <stream:stream xmlns:stream=“http://etherx.jabber.org/streams” version=“1.0” xmlns=“jabber:client” to=“gmail.com” xml:lang=“en” xmlns:xml=“http://www.w3.org/XML/1998/namespace”></stream:stream>
  • Gtalk Acknowledge With >>
    1. <!–?xml version=”1.0″ encoding=”UTF-8″?–>
    2. <stream:stream from=“gmail.com” id=“1DA3DFD778DA0116” version=“1.0” xmlns:stream=“http://etherx.jabber.org/streams” xmlns=“jabber:client”>
    3. <stream:features>
    4.   <bind xmlns=“urn:ietf:params:xml:ns:xmpp-bind”>
    5.   <session xmlns=“urn:ietf:params:xml:ns:xmpp-session”>
    6. </session></bind></stream:features></stream:stream>
  • JAXL Sends >>
    1. <iq type=“set” id=“1”>
    2.   <bind xmlns=“urn:ietf:params:xml:ns:xmpp-bind”>
    3.     <resource>jaxl</resource>
    4.   </bind>
    5. </iq>
  • Gtalk Acknowledge With >>
    1. <iq id=“1” type=“result”>
    2.   <bind xmlns=“urn:ietf:params:xml:ns:xmpp-bind”>
    3.     <jid>myproductionuser@gmail.com/jaxl25C3CD9A</jid>
    4.   </bind>
    5. </iq>
  • JAXL Sends >>
    1. <iq type=“get” to=“gmail.com”>
    2.   <query xmlns=“http://jabber.org/protocol/disco#info”>
    3. </query></iq>
  • Gtalk Acknowledge With >>
    1. <iq to=“myproductionuser@gmail.com/jaxl25C3CD9A” from=“gmail.com” type=“result”>
    2.   <query xmlns=“http://jabber.org/protocol/disco#info”>
    3.     <identity category=“server” type=“im” name=“Google Talk”>
    4.     <feature var=“http://jabber.org/protocol/disco#info”>
    5.     <feature var=“google:jingleinfo”>
    6.     <feature var=“google:roster”>
    7.     <feature var=“google:nosave”>
    8.     <feature var=“google:setting”>
    9.     <feature var=“google:shared-status”>
    10.     <feature var=“http://jabber.org/protocol/archive#otr”>
    11.     <feature var=“google:mail:notify”>
    12.     <feature var=“http://jabber.org/protocol/archive#save”>
    13.   </feature></feature></feature></feature></feature></feature></feature></feature></feature></identity></query>
    14. </iq>
  • JAXL Sends >>
    1. <iq type=“get” id=“2”>
    2.   <query xmlns=“jabber:iq:roster”>
    3. </query></iq>
  • Gtalk Acknowledge With >>
    1. <iq to=“myproductionuser@gmail.com/jaxl25C3CD9A” id=“2” type=“result”>
    2.   <query xmlns=“jabber:iq:roster”>
    3.     <item jid=“friend_1@gtalkbots.com” subscription=“both”><group>Buddies</group></item>
    4.     <item jid=“friend_2@gmail.com” subscription=“both”>
    5.     <item jid=“friend_3@gmail.com” subscription=“both”><group>Buddies</group></item>
    6.     <item jid=“friend_4@gmail.com” subscription=“both” name=“Abhinav Singh”>
    7.     <item jid=“friend_5@gmail.com” subscription=“both”><group>Buddies</group></item>
    8.     <item jid=“friend_6@yahoo.co.in” subscription=“none” ask=“subscribe”>
    9.   </item></item></item></query>
    10. </iq>
  • JAXL Sends >>
    1. <presence from=“myproductionuser@gmail.com/jaxl25C3CD9A” to=“friend_6@yahoo.co.in” type=“subscribed”>
    2. <presence>
    3.   <show>chat</show>
    4.   <status>Online using JAXL – Jabber XMPP Library</status>
    5. </presence></presence>
  • Gtalk Acknowledge With >>
    1. <presence from=“friend_1@gtalkbots.com/gtalkbots.BCFBAC47” to=“myproductionuser@gmail.com/jaxl25C3CD9A”>
    2.   <status>I am online using Gtalkbot’s Client Library (JAXL)</status>
    3.   <x xmlns=“vcard-temp:x:update”>
    4. <photo>7d29d807158fd64820b109b4b42b2a23ca5a9d5a</photo>
    5.   </x>
    6. </presence>

And in this fashion JAXL Client and Gtalk Server keeps exchanging XML Streams when ever there is a new message or an update in friend’s status message.

For more detail and in-depth knowledge kindly refer to the RFC documents linked at the top.

PS: After publishing this post on January 2, 2009, it mysteriously vanished sometime between between March 8, 2010 and April 18, 2010. Today on Feb 1, 2015 while updating my blog theme I found about it via google webmaster tool and was able to recover using web.archieve.org