I am having issues accessing payload data from a pubsub application. I am receiving the pubsub event correctly, but the payload data has null for each tag in the XML message.
For example:
Lord of the Rings
is received as
nullnullLord of the Ringsnullnull
I am seeing this on both the sender’s loopback and receiver side.
Here is my node initiation:
private void pubsubStartServer(String node) throws XMPPException
{
ConfigureForm form = new ConfigureForm(FormType.submit);
form.setPersistentItems(false);
form.setDeliverPayloads(true);
form.setAccessModel(AccessModel.open);
form.setSubscribe(true);
form.setPublishModel(PublishModel.publishers); //
// Create pubsub node. If pubsub node exists, delete it
// and recreate it.
//
// XXX: This might need to change if multiple server applications
// are expected. Instead it should look if the node exists
// and connect to it instead of deleting it. This would have
// implications on the stop routine as well.
try{
myNode = (LeafNode) manager.createNode(node, form); }catch(XMPPException e)
{
Log.d("xmpp-debug","createNode e:" + e.toString()); // delete node
try{
manager.deleteNode(node);
Log.d("xmpp-debug","deleteNode:"+node);
}catch(XMPPException e1)
{
Log.d("xmpp-debug","deleteNode e:" + e1.toString());
} // recreate the node (let exception throw to caller)
myNode = (LeafNode) manager.createNode(node, form); }
}
Here is my send code:
public void sendMsg(String msgXML){
// simple payload set element name and namespace to null
// then msg must be well formed xml
SimplePayload payload = new SimplePayload("","", "<message/>");
PayloadItem<SimplePayload> item = new PayloadItem<SimplePayload>(null, payload); // Publish item
//myNode.publish(item); try {
myNode.send(item);
} catch (XMPPException e) {
// TODO Auto-generated catch block
Log.d("xmpp-debug","XMPP:send:e" + e.toString());
} Log.d("xmpp-debug", "XMPP:sendmsg:" + item.getPayload().toXML());
}
LogCat: XMPP:sendmsg:
Here is my receive class:
class ItemEventCoordinator implements ItemEventListener<PayloadItem<SimplePayload>> {
public void handlePublishedItems(ItemPublishEvent<PayloadItem<SimplePayload>> items) { for(int i = 0; i<items.getItems().size();i++)
{
PayloadItem<SimplePayload> payload = (PayloadItem<SimplePayload>) items.getItems().get(i); Log.d("xmpp-debug","XMPP:payload:" + payload.getPayload());
} }
}
LogCat: XMPP:payload:org.jivesoftware.smackx.pubsub.SimplePayloadpayload [null]
Thanks in advance, I have looked through the documentation and forums and can’t make heads or tails of this.
-Todd