开发者

Migration from Flex 3 to Flex 4.5: problem with network format

I'm currently migrating a large project from Flex 3 to Flex 4.5. The problem I'm stuck on is network communication: we're using a custom protocol that we embed in AMF3, but it seems the messages sent by flash.net.NetConnection aren't readable.

Our Java back-end uses some BlazeDS classes to deserialize the message, namely flex.messaging.io.amf.AmfMessageDeserializer.AmfMessageDeserializer, and I can monitor the network traffic with Charles Web Proxy which decodes AMF3. The very simple code herebelow sends a message that can be decoded by Charles when compiled in Flex 3.5, but not in Flex 4.5 (I get "Failed to parse data (com.xk72.amf.AMFException: Unsupported AMF3 packet typ开发者_开发百科e 17 at 26").

import mx.controls.Alert;

private function init():void
{
    var pdl : Dictionary = new Dictionary();

    var connection : NetConnection = new NetConnection();
    connection.connect("http://localhost");

    var responder : Responder = new Responder(result);
    connection.call("net", responder, pdl);
}

private function result(pdl : Object) : void {
    Alert.show("coucou", "hello");
}

I've set up an apache server at localhost:80 to test this.

Has anyone used NetConnection in Flex 4.5 and encountered deserialization problems? How did you solve them?

Thanks,

Daniel


AMF3 has a bunch of different core types it can serialize. One of those core types is new to AMF3 in the past year or two, Dictionary, and it has a "packet type" of 17, thus the error message. I'm not sure why Flex 3 would serialize it as something other than a Dictionary and Flex 4.5 would serialize it as the new Dictionary type, but you're getting an error because your BlazeDS backend doesn't support the new Dictionary type.

The solution is to either figure out what it was sending as in Flex 3 and switch to that, or to upgrade BlazeDS (there seems to have been a patch added to BlazeDS last year for Dictionary http://forums.adobe.com/thread/684487).

edit: Didn't realize that the error was with Charles. Charles probably hasn't added support for Dictionary, as it's not part of the documented AMF3 specs. Have you tried the beta of Charles?


Since you're working with legacy code, you may need to set the NetConnection's objectEncoding property manually before you make the connection. You can set the connection's objectEncoding with the help of the ObjectEncoding class.

What version of Flash Player are you using?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜