Datasheet
16
CHAPTER 1 GettinG to Know XMPP
type=’error’
id=’roster1’>
<query xmlns=’jabber:iq:roster’/>
<error type=’cancel’>
<feature-not-implemented xmlns=’urn:ietf:params:xml:ns:xmpp-stanzas’/>
</error>
</iq>
Jane sent a malformed roster retrieval request to her server. The server replied with an error. Error
stanzas are covered in detail later.
<iq from=’jane@longbourn.lit/garden’
type=’get’
id=’roster2’>
<query xmlns=’jabber:iq:roster’/>
</iq>
<iq to=’jane@longbourn.lit/garden’
type=’result’
id=’roster2’>
<query xmlns=’jabber:iq:roster’>
<item jid=’elizabeth@longbourn.lit’ name=’Elizabeth’/>
<item jid=’bingley@netherfield.lit’ name=’Bingley’/>
</query>
</iq>
After resending a corrected request, the server replied to Jane with her small roster. You can see that
Elizabeth and Bingley are both in Jane’s contact list.
<iq from=’jane@longbourn.lit/garden’
type=’set’
id=’roster3’>
<query xmlns=’jabber:iq:roster’>
<item jid=’darcy@pemberley.lit’ name=’Mr. Darcy’/>
</query>
</iq>
<iq to=’jane@longbourn.lit/garden’
type=’result’
id=’roster3’/>
Jane attempts to add Mr. Darcy to her roster, and the server indicates success with a blank
IQ-result. In the cases where the response is simply an acknowledgment of success, the IQ-result
stanza will often be empty.
The
<iq> stanza is quite useful in any case where result data or simple acknowledgment is required.
Most XMPP extension protocols use a mix of
<iq> and <message> stanzas to accomplish their goals.
The
<iq> stanzas are used for things like configuration and state changes, whereas <message> stan-
zas are used for regular communication. In some cases
<iq> stanzas are used for communication
because stanza acknowledgment can be used for rate limiting.
40718c01.indd 16 11/30/09 8:23:50 PM