powered by Jive Software

Why isn't my custom IQ provider working?

I’m trying to set up some custom IQ packet handling, using Smack as part of an Android project. My client code sends and receives chat messages with no problem, but I haven’t managed to get it to respond to IQ messages – every time I send one to the client, it gets bounced back as ‘feature-not-implemented’. I’ve read the Provider Architecture document, and quite a lot of source code on the net, but I must be doing something wrong. I’m new to Smack, and kind of a noob with Java, so it may well be something obvious.

Here’s a message I’m sending to the client (using another custom client on the desktop, via a localhost instance of Openfire):

<iq to=“user@myserver/android” from=“user@myserver/CTest” type=“get” id=“query8”>

<query xmlns=“mynamespace:iq:contacts”/>

</iq>

And here’s what comes back:

<iq id=“query8” to=“user@myserver/CTest” from=“user@myserver/android” type=“error”><error code=“501” type=“CANCEL”><feature-not-implemented xmlns=“urn:ietf:params:xml:ns:xmpp-stanzas”/></error></iq>

Here’s the relevant chunk of code, which gets called after the XMPP login:

public void setConnection (XMPPConnection connection) {
         this.connection = connection;
         if (connection != null) {
              // Add a packet listener to get chat messages sent to us
              //  -- deleted -- (works fine)               // add IQ provider for ContactQuery
              ProviderManager providerManager = ProviderManager.getInstance();
              providerManager.addIQProvider("query", "mynamespace:iq:contacts", ContactQuery.class);           // add packet listener for ContactQuery
          connection.addPacketListener(new PacketListener() {
                   public void processPacket(Packet p) {
                        ContactQuery ep = (ContactQuery)p;
                        Log.i("MyApp", "Receive ContactQuery ");
                   }}, new PacketTypeFilter(ContactQuery.class));
          }
  }

The debugger confirms that my class ContactQuery is getting added to the list of iqProvider (as <query/><mynamespace:iq:contacts/>=class com.mydomain.mobile.demo.ContactQuery). I’m not sure what to look at to determine where things go wrong.

Any suggestions?

Thanks for your help!