Hi Everyone,

I'm updating a Point of Sale system that was built with Flex and AIR using the Cairngorm framework.

The code integrates with a custom server provided by my client's payment processor vendor. Part of their requirement is that parameters be form posted to their server in a specific order. The Apache Flex framework does not appear to retain the parameter order of the object's parameters. Has anyone run into this before?

 More specifics, with code:

1) Service object set up in the Cairngorm Services.mxml:

    <mx:HTTPService id="service"
                    showBusyCursor="false"
                    requestTimeout="240"
method="post" contentType="application/x-www-form-urlencoded"
                    url="http://localhost.:16448/"; resultFormat="e4x"
                    />

2) Create Parameter object and call service method; this is done in a Cairngorm Delegate:

var parameters : Object = new Object();
parameters.firstParameter  = "firstOne";
parameters .amount = 100;
parameters .otherParameters = "Other Random Misc Data";
parameters.lastParameter = "LastOne";

Then make the call:

var call : Object    = this.service.send(parameters);
call.addResponder( this.responder );

3) Flex Framework class mx.rpc.httpAbstractOperation, starting around line 862. This appears to loop over properties using classinfo.properties . This seems to get an alphabetical list of properties from my object and add them to the paramsToSend object:


        else if (ctype == CONTENT_TYPE_FORM)
        {
            paramsToSend = {};
            var val:Object;

            if (typeof(parameters) == "object")
            {
//get all dynamic and all concrete properties from the parameters object
                var classinfo:Object = ObjectUtil.getClassInfo(parameters);

                for each (var p:* in classinfo.properties)
                {
                    val = parameters[p];
                    if (val != null)
                    {
                        if (val is Array)
                            paramsToSend[p] = val;
                        else
                            paramsToSend[p] = val.toString();
                    }
                }
            }
            else
            {
                paramsToSend = parameters;
            }
        }

4) Looking at the raw data in the Flash Builder Network Monitor; the final request doesn't have the parameters in alphabetical order.

otherParameters=Other%20Random%20Misc%20Data&lastParameter=LastOne&firstParameter=firstOne&amount=100

With this small sample it appears that the parameters are in reverse alphabetical order, but with the actual request data they are in a seemingly random--but always consistent--order.


-------

Thanks for reading this far. My first attempt at a solution was to create the POST parameter string manually and use that as the parameter object. However in that case the body of the POST request was blank when reviewing it in the service monitor.

  So, has anyone run into this before?  What was your solution?



--

Jeffry Houser
Technical Entrepreneur
http://www.dot-com-it.com
http://www.jeffryhouser.com
203-379-0773

Reply via email to