powered by Jive Software

Whack''s Packet serialization

Hi !

I’‘m using whack’'s Packet for send packets from msn gateway to server. There is possible problem with serialization. iq:query packets looks like :

Please enter your MSN Messenger account and password. Nickname is optional.

You can see empty xmlns tag. I don’'t see any value for xmlns. Is it right behavior ?

WBR, Alex.

Alex,

I assume that you’‘re creating the iq:register packet yourself? Can you paste in the code that you’‘re using to do so? I don’'t think you should be getting empty xmlns elements normally.

-Matt

See gateway packet - it’'s more simple:

MSN Address

Please enter the MSN Address of the person you would like to contact.

IQ reply = iqPacket.createCopy();

reply.setType(IQ.Type.result);

reply.setTo(iqPacket.getFrom());

reply.setFrom(iqPacket.getTo());

Element queryElement = reply.getChildElement();

addChild(queryElement, “prompt”, getPrompt());

addChild(queryElement, “desc”, getDesc());

protected void addChild(final Element parent, final String tag, final String text) {

if (text != null) {

final Element child = DocumentHelper.createElement(tag);

child.setText(text);

parent.add(child);

}

}

Alex,

My guess is that the DocumentHelper class is messing things up somehow. Instead, we usually use code that looks like the following:

queryElement.addElement(“prompt”).setText(getPrompt());

queryElement.addElement(“desc”).setText(getDesc());

Regards,

Matt

Matt,

You are correct. When creating a new element using the DocumentHelper the namespace is assumed to be new (i.e. empty) so when adding the new element to the parent element it is assumed that the new element is under a different namespace. As you said, the correct way to add a new element under the parent’'s namespace is to send #addElement to the parent.

Regards,

– Gato