I have a Message object in java wgich I am coverting to payload:
PayloadItem topicPayload=new PayloadItem(msg);
and publishing the topicPayload.
This is my payload:
<Message xmlns="http://jabber.org/protocol/pubsub"><sender>username</sender><receiver>receiver</receiver><password>password123</password><body>Message_body</body></Message>
But when I am trying to get the items from the node using node.getItems(), It gives me following exception:
java.lang.IllegalArgumentException: Could not determine namespace from XML payload
at org.jivesoftware.smack.util.StringUtils.requireNotNullOrEmpty(StringUtils.java:449) ~[smack-core-4.3.4.jar:4.3.4]
at org.jivesoftware.smackx.pubsub.SimplePayload.(SimplePayload.java:61) ~[smack-extensions-4.3.4.jar:4.3.4]
at org.jivesoftware.smackx.pubsub.provider.ItemProvider.parse(ItemProvider.java:62) ~[smack-extensions-4.3.4.jar:4.3.4]
at org.jivesoftware.smackx.pubsub.provider.ItemProvider.parse(ItemProvider.java:40) ~[smack-extensions-4.3.4.jar:4.3.4]
at org.jivesoftware.smack.provider.Provider.parse(Provider.java:43) ~[smack-core-4.3.4.jar:4.3.4]
at org.jivesoftware.smack.util.PacketParserUtils.parseExtensionElement(PacketParserUtils.java:918) ~[smack-core-4.3.4.jar:4.3.4]
at org.jivesoftware.smack.util.PacketParserUtils.addExtensionElement(PacketParserUtils.java:1001) ~[smack-core-4.3.4.jar:4.3.4]
at org.jivesoftware.smack.util.PacketParserUtils.addExtensionElement(PacketParserUtils.java:995) ~[smack-core-4.3.4.jar:4.3.4]
at org.jivesoftware.smack.provider.EmbeddedExtensionProvider.parse(EmbeddedExtensionProvider.java:101) ~[smack-core-4.3.4.jar:4.3.4]
at org.jivesoftware.smack.provider.EmbeddedExtensionProvider.parse(EmbeddedExtensionProvider.java:82) ~[smack-core-4.3.4.jar:4.3.4]
at org.jivesoftware.smack.provider.Provider.parse(Provider.java:43) ~[smack-core-4.3.4.jar:4.3.4]
at org.jivesoftware.smack.util.PacketParserUtils.parseExtensionElement(PacketParserUtils.java:918) ~[smack-core-4.3.4.jar:4.3.4]
at org.jivesoftware.smack.util.PacketParserUtils.addExtensionElement(PacketParserUtils.java:989) ~[smack-core-4.3.4.jar:4.3.4]
at org.jivesoftware.smack.util.PacketParserUtils.addExtensionElement(PacketParserUtils.java:984) ~[smack-core-4.3.4.jar:4.3.4]
at org.jivesoftware.smackx.pubsub.provider.PubSubProvider.parse(PubSubProvider.java:46) ~[smack-extensions-4.3.4.jar:4.3.4]
at org.jivesoftware.smackx.pubsub.provider.PubSubProvider.parse(PubSubProvider.java:34) ~[smack-extensions-4.3.4.jar:4.3.4]
at org.jivesoftware.smack.provider.Provider.parse(Provider.java:43) ~[smack-core-4.3.4.jar:4.3.4]
at org.jivesoftware.smack.util.PacketParserUtils.parseIQ(PacketParserUtils.java:616) ~[smack-core-4.3.4.jar:4.3.4]
at org.jivesoftware.smack.util.PacketParserUtils.parseStanza(PacketParserUtils.java:157) ~[smack-core-4.3.4.jar:4.3.4]
at org.jivesoftware.smack.AbstractXMPPConnection.parseAndProcessStanza(AbstractXMPPConnection.java:1084) ~[smack-core-4.3.4.jar:4.3.4]
at org.jivesoftware.smack.tcp.XMPPTCPConnection.access$1300(XMPPTCPConnection.java:155) ~[smack-tcp-4.3.4.jar:4.3.4]
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1144) ~[smack-tcp-4.3.4.jar:4.3.4]
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$1000(XMPPTCPConnection.java:1092) ~[smack-tcp-4.3.4.jar:4.3.4]
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:1112) ~[smack-tcp-4.3.4.jar:4.3.4]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_222]
Why is namespace required and how to insert it in payload?