The IQ Element
The third and final element in the Jabber building block set is the
<iq/> element (“iq” stands
for “info/query”), which represents a mechanism for sending
and receiving information. What the
<iq/> element has over
the <message/> element for
this purpose is structure and inherent meaning. It is useful to liken
the info/query mechanism to the request/response model of HTTP using GET and POST.
The <iq/> element allows a
structured conversation between two Jabber entities. The conversation exists
to exchange data, to retrieve or set it, and to notify the other
party as to the success (or not) of that retrieve or set action. There are
four states that an <iq/>
element can be in, each reflecting one of the activities in this conversation:
- get
Get information.
- set
Set information.
- result
Show the result when the
getorsetwas successful.- error
Specify an error if the
getorsetwas not successful.
These states are reflected in the type attribute
of <iq/> elements.
The relationship between two entities in such a structured conversation
that convey these states is shown in
Figure 5-4.
![]() |
Note
As you can see, the combination of the <iq/>
element specification and the type attribute is written
like this:
IQ-type
For example, “IQ-get” refers to an <iq/>
element with type='get', and so on.
Earlier in this chapter, we saw ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access
