powered by Jive Software

IQ protocol between 2 clients using smack

Hello out there!

I need to implement a message exchange between 2 clients based on the IQ protocol and I am a bit lost trying to find out how to do it with the smack api.

The client I need to extend is based on smack 2.2.1 and smackx 2.2.1, and as server we are using a wildfire server version 3.1.0.

I would be so nice, if anyone could point me to a direction or provide me with any kind of advice…

I want to send something like this:

… but I can not find any setChildElementXML(String queryXml) method in any subclass of IQ.

Which would be the concrete base class for my packet???

Thanks a lot in advance!


Hi Ruth,

While you could add a setChildElementXML method to your IQ class the more common approach is to do the following:

public class Something extends IQ {
   private String something;
      public Something() {
      public void setSoemthing(String something) {
      this.something = something;
   }    public String getChildElementXML() {
       StringBuffer sb = new StringBuffer();
       sb.append("<query xmlns=\"myNamespace:iq:getSomething\">");
       return sb.toString();

Hope that helps,


thank you so much, Ryan, I’'ll try it out immediately and let you know!

Thank you again - and yes: it does work perfectly well!

I might come back with questions about the receiving process though… There is no howTo or tutorial about implementing customized iq protocols, is there?

Have a nice day!