I have an IQHandler added in my plugin:
iqHandler = new IQHandler(“Olive3 SYNC request handler”) {
IQHandlerInfo info = new IQHandlerInfo(“query”,SYNC_NS);
public IQHandlerInfo getInfo() {
return info;
}
public IQ handleIQ(IQ iq) throws UnauthorizedException {
log("received sync server request: "+iq.toXML());
IQ reply = IQ.createResultIQ(iq);
Element childElement = iq.getChildElement();
String namespace = childElement.getNamespaceURI();
log("namespace was: "+namespace);
Element childElementCopy = iq.getChildElement().createCopy();
reply.setChildElement(childElementCopy);
childElementCopy.addAttribute(“jid”, componentJID.toString());
log("sending “+iq.getTo()+”: "+reply.toXML());
return reply;
}
};
I have a smack client that connects up, sends an IQ with query element including the correct namespace:
The IQHandler handles this and in the log before returning ‘reply’ i get:
sending null:
The problem is the client only gets this:
The child XML is always null. Is there something i need to do additionally?
IQ handshake in the smack client is pretty simple:
IQ iq = new IQ() {
public String getChildElementXML() {
StringBuilder buf = new StringBuilder();
buf.append("<query xmlns=“test:iq:sync”/>");
return buf.toString();
}
};
System.out.println("Sending IQ: "+iq.toXML());
PacketFilter filter = new AndFilter(new PacketIDFilter(iq.getPacketID()),
new PacketTypeFilter(IQ.class));
PacketCollector collector = getConnection(0).createPacketCollector(filter);
// Send the iq packet with an invalid namespace
getConnection(0).sendPacket(iq);
IQ result = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
// Stop queuing results
collector.cancel();
if (result == null) {
fail(“No response from server”);
return;
}
System.out.println("received result: "+result.toXML());
if (result.getType() != IQ.Type.RESULT) {
fail("The server replied with: "+result.toXML());
}
else if (result.getChildElementXML() == null) {
fail(“The server replied with null child xml”);
}
Any help is appreciated.