XML-RPC Client Library for ActionScript

Current version: 0.3.1 beta

This is an XML-RPC client implementation for ActionScript 2.0. The usage is very similar to the Flash Remoting for MX 2004 ActionScript 2.0 components, so it should be pretty easy for anyone with Flash Remoting experience to learn to use this library as well. (It shouldn’t be hard for others to learn to use it either — I just wanted to build it to follow a well-established pattern for calling remote methods in ActionScript.)

In addition, this library provides a base class which can be extended to create your own strongly-typed “service” class, which will allow you to have compile-time type checking while using this library — an extra bonus for those of you (like me) who really like compile-time type checking.

You can:

I want this to be useful (and improved upon), so it is being distributed under a pretty open license — the most noteworthy clause is that if you improve the code (of this library specifically), you should pass those improvements back to be included in the core distribution (sort of like LGPL — you don’t have to share any code that isn’t specifically a modification to this library).

Please use the comments section of this page or contact me directly to leave feedback, comments, bug reports, etc. As bugs are fixed, the comments will be updated.

You can leave a comment, or trackback from your own site.

  • Pingback: William Brown Street

  • http://n/a Markus

    We’ve found an error in your XML-RPC Client Library. According to the XML-RPC specification the HTTP Content-Type header is text/xml. In your library the Content-Type in the HTTP Header is application/x-www-form-urlencoded. It can be fixed with 1 single line:

    public function serializeRequest(methodName:String, args:Array):XML
    {
    var result:XML = new XML();
    result.ignoreWhite = true;
    result.contentType = “text/xml”; //////// add this line please
    result.xmlDecl = “”;

    regards

    Markus

    [Paul: Thanks for the report Markus! This has been fixed in version .3.1]

  • Robert

    I’m having difficulties getting my Flash app to communicate with a Java server. Flash runs fine up until this line myPendingCall.responder = new RelayResponder2(this, sumResult, sumFault);

    I get an error in the compile of type mismatch: found com.probertson.rpc.Relayresponder2 where mx.rpc.Responder is required

    Using a Responder seems to make no difference

    I’m using actionscript 2 in Flash CS3 and followed the step-by-step guide to the letter

  • Pingback: [flexcoders] QTP Automation Interface

  • Pankaj Chawla

    Hi Paul,

    Did you finally port the XML-RPC to AS3.0. If yes, I will be interested to check it out.

  • Jeff

    Hi,
    I can’t figure out how to get values into a struct. I’ve made my inplementations of the IXmlRpcStruct interface, so my struct has all the right members and their names, but all the value nodes are empty.

    I have included code along the lines of the following…

    var myStruct:serverInfoStruct = new serverInfoStruct ('value1', 'value2');

    why do my struct members have empty value nodes?

    I’m trying to use this to load openX advertisements into flash, and part of the requirements for thier xmlrpc call is a struct within a struct, much like an array where one of the elements is another array. Is that possible?

  • Pingback: XML-RPC vs. Flash-Client - Flashforum

  • Jean-Francois

    Hi,

    I’m a newbie in flash. But I think I found a little bug in the rpc serializer, file ‘serializer.as’.

    In this code snippet:

    else if (arg instanceof Array)
    {
    typeNode = xml.createElement(“array”);
    var dataNode:XMLNode = xml.createElement(“data”);
    var arrayVal:Array = Array(arg);
    var numElements:Number = arrayVal.length;
    for (var i:Number = 0; i < numElements; i++)
    {
    dataNode.appendChild(createParamNode(xml, arrayVal[i]));
    }
    typeNode.appendChild(dataNode);
    }

    the variable arrayVal:Array = Array(arg) is created but only containes 1 element, the 'arg' array.
    With this array, and the method calling itself in recursion, flash crash with a stack error.

    I changed it to iterate over the arg parameter instead.
    Here's the code I wrote:
    else if (arg instanceof Array)
    {
    typeNode = xml.createElement("array");
    var dataNode:XMLNode = xml.createElement("data");
    var numElements:Number = arg.length;
    for (var i:Number = 0; i < numElements; i++)
    {
    dataNode.appendChild(createParamNode(xml, arg[i]));
    }
    typeNode.appendChild(dataNode);
    }

    Just wanted to let you know. Also, as I said, I'm new to flash, so I might be wrong with my 'fix', but it now works on my side.

    JF

Articles by Type

Articles by Topic

Random Reading

Currently...

Adobe MAX 2011 Speaker H. Paul Robertson: Adobe Community Professional

Subscribe