powered by Jive Software

Custom Packet Extension with no Provider


I’m trying to send custom PacketExtension’s through smack but I dont want to parse them. The application receiving the packets is simply forwarding them to different classes which are doing their own XML parsing. Therefore, I dont want to have to write a PacketExtentionProvider for the various xml documents which are going to be flying through my server. How can I do this?


I believe that by default the extensions will get read into a DefaultPacketExtension, from which you can simply extract the XML by calling the toXML() method. This requires no explicit provider or extra work on your part.

I created a class which implemented a PacketExtension and took in a Document in its constructor, it uses the root element to get the element name and namespace and the toXML returns a String XML of the entire document.

When I was trying to pass Messages with my CustomPacketExtension objects I would see them go off the wire from the sender with a PacketSendingListener but they were never received by the destination. If I commented out the addition of the extension, the destination would receive it fine. It seems as if the packet is silently being dropped without any errors which was extremely difficult to debug.

I dont think using DefaultPacketExtensions toXML will work because the only way I can set data into those is by using the get/set methods.

Since you were referring to parsing and the receiving application, I was only addressing the receiver, not the sender.

By the way, you can monitor all incoming/outgoing messages by setting -Dsmack.debugEnabled=true. This will open up a console with all XMPP messages, including raw format. Great for debugging message content and whether messages are being sent/received.