powered by Jive Software

Smack and Jive problem

hi everyone,

i have an application where i use the smack library to connect to jive and

send and receive messages. everything is alright, except by some characters,

like >,< and some others, cause when i try to send them by my java program,

the client receive the characters like &gt or &lt…

does anyone knows how to solve that?

thks for your help,

Fernando

What client is recieving these characters? A client you created or what? What you see in place of < and > is there encodings because they are reserved characters in XML. As far as I know smack can read these okay… what client are you using on the other end?

Alex

Im using Gaim for linux in the other end,

and instead of > and <, Im seeing &gt and &lt, that are the codes for these

chars. I guess smack is putting the code into the xml and someone is not converting

it back to its format. when i was not using smack, and i was bulding the xml myself,

it was working.

Fernando

Can you post the XML you were using and the XML that Smack was sending? It would be preferable to see the XML in the Raw Sent Packets tab of the Smack debugger.

Alex

Here it is:

xml i was sending:

. And in the second one i really dont know what the &amp means, but they dont show in the message.

Fernando

so, the actual message you are sending is:

Resultado do envio: 5199774566 >>> OK ?

What is the exact method call you are using inside smack to send this message? It looks like your message is being XML escaped twice… & is the XML code for “&”

Alex

Thats right, thats my message.

ill paste my entire code for this message, so you can see what im doing worng:

String sendStatus = “Resultado do envio: 5199774566 >>> OK”.

jabber.sendXMLMsg(message.jid,sendStatus);

// call this method

public void sendXMLMsg(String jid, String body) {

Message msg = new Message(jid,Message.Type.CHAT);

msg.setBody(StringUtil.escapeXml(body)); // could this be the problem?

sendXML(msg);

}

// call this method

private void sendXML(Packet msg){

try {

con.sendPacket(msg); //sends the message throught the connection

} catch (Exception e) {

e.printStackTrace();

}

}[/code]

if u need any more information, just ask me.

Tnx,

Fernando

Yea,

msg.setBody(StringUtil.escapeXml(body));[/code]

should be:

msg.setBody(body);[/code]

If you trace the call hierachy of StringUtil#escapeXml(), you will see that it is called when changing a message from a Message object to an XML string using the toXML() string. It was good to think ahead on this though.

Alex