powered by Jive Software

Sending message exception

We’re investingting XIFF with our 100% Flexed based CRM application. Right now, we’re creating a simple driver Flex application to test the API. We’ll be happy to contribute the Flex driver application once it is done and if the community would like it.

Trying to get over some hurdles. In sending a message, we get an exception:

Error #1034: Type Coercion failed: cannot convert org.jivesoftware.xiff.data.xhtml::XHTMLExtension@162e241 to org.jivesoftware.xiff.data.ISerializable.
at org.jivesoftware.xiff.data::XMPPStanza/serialize()[C:\Documents and Settings\John\My Documents\Flex Builder 3\XIFF\src\org\jivesoftware\xiff\data\XMPPStanza.as:116]
at org.jivesoftware.xiff.data::Message/serialize()[C:\Documents and Settings\John\My Documents\Flex Builder 3\XIFF\src\org\jivesoftware\xiff\data\Message.as:86]
at org.jivesoftware.xiff.core::XMPPConnection/send()[C:\Documents and Settings\John\My Documents\Flex Builder 3\XIFF\src\org\jivesoftware\xiff\core\XMPPConnection.as:306]

We added the serialize( parent:XMLNode) : Boolean and deserialize( node:XMLNode ) : Boolean methods to XHTMLExtension.as file as suggested in another post, we got the above error.

With:

var msg : Message = new Message( null, null, ‘Hello World’, ‘Hello World’, null, Message.CHAT_TYPE );

this.open_fire_server.send( msg );

we get the error

With:

var msg : Message = new Message( null, null, ‘Hello World’,null, null, Message.CHAT_TYPE );

this.open_fire_server.send( msg );

we dont get the error, but nothing in repsonse and a different error:

Error: Error #2002: Operation attempted on invalid socket.
at flash.net::Socket/writeUTFBytes()

We’re pretty good with Action Script and Flex, so we are eager to help to get XIFF out of beta. It will be crititcal of our CRM application to have this work. Just need to guidance and assistance to get over the bumps.

I never used the fourth parameter (msgHTMLBody:String) of Message type to send a message. Currently I just use its third parameter, msgBody. What reason do you need to use msgHTMLBody? Anyway, let us know.

That will be nice if you can contribute to XIFF; recently there has been a demand to have more commits to the repository.

Hey jteg, I ran into exactly the same problem today when I was trying to learn about XIFF. I created a little flex client and connected to my jabber server then I logged in using ichat. When I sent a message from ichat -> my flex client, I got the exact same error you do. So I dug around and I think I can give you at least 1/2 a fix I don’t really know the consequences of my actions but it seems to work just fine after this. Maybe someone with more knowledge can tell me why I’m wrong.

Looks like the XHTMLExtension class doesn’t implement the ISerializable class. So first change the XHTMLExtention class declaration to:

public class XHTMLExtension extends Extension implements IExtension, ISerializable

Now you need to add the two methods that are expected of an ISerializable class:

public function deserialize( node:XMLNode ):Boolean
{
return true;
}

    public function serialize( parent:XMLNode ):Boolean
    {
        return false;
    }

I’ve only been using XIFF for about 2 hours at this point so I don’t really know how those two functions are supposed to be used, but I’d assume you might want to put some real code in there to serialize and deserialize the HTML elements. As it stands now this stops the error and my text chat’s get through from ichat so I’m reasonably happy. If you make it better, let me know. Hope that helps.

-Eric

Hey Eric,

I’m assuming you are using the beta download version. You might want to checkout the trunk instead, a fix has already been committed.

In response to why you would need to use it, I am running into a small issue where users can’t send out XML-esque test in chat (anything with a left carat will cause the whole message to not show up on the other end).

I believe using htmlBody would solve this issue?