Can I control the parameter order in an HTTPService Post?

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Can I control the parameter order in an HTTPService Post?

Jeffry Houser
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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can I control the parameter order in an HTTPService Post?

kamcknig
When iterating over properties in ActionScript there is no guarantee of the
order unfortunately. I can't think of a front-end solution that would solve
this problem. I believe the only solution would be on the server's side.

Kyle


Kyle McKnight
Senior UI Engineer - Accesso
602.515.1444 (M)

On Tue, Jul 4, 2017 at 10:55 AM, Jeffry Houser <[hidden email]>
wrote:

> 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(parame
> ters);
>
>                 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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can I control the parameter order in an HTTPService Post?

Javier Guerrero García
In reply to this post by Jeffry Houser
Hi Jeffrey!

My 4 cents :)

1. Maybe defining the <mx:request> inside the <mx:HTTPservice> declaration
(and just binding the contents) helps somewhat. Maybe not, but at least
it's prettier :)
http://help.adobe.com/en_US/Flex/4.0/AccessingData/WS2db454920e96a9e51e63e3d11c0bf69084-7fdc.html

2. Stupid one: try method="POST" (uppercase), just in case :)

3. According to the mx.rpc.httpAbstractOperation code, if typeof(parameters)
== "object" it iterates and messes up with the order, but if it's not, it
should just copy it to "paramsToSend" ("else paramsToSend=parameters;").
BUT, on some HTTP request implementations (for instance jQuery, not sure
about flex), if you pass a string instead of a proper object as data, it
"assumes" you want to make a GET instead of a POST. Are you 100% sure that,
when you pass "parameters" as a string, you are issuing an empty *POST*
request?

4. Instead of Flash network monitor, just get a quick PHP somewhere and
monitor exactly what is arriving (and how) in your HTTP call (a simple
<?php var_dump($_REQUEST); ?> would do). I'm not really sure if the sorting
is done by the monitor itself, and I'm really perplexed about
ObjectUtil.getClassInfo(parameters) does sort the object properties
alphabetically (what a waste of CPU cycles!).


P.S. And please, fire/kill the intern who programmed the server side
trusting the order of the parameters.... I'm sure there is an RFC somewhere
that you can throw at his face explicitly stating that params order should
NOT be relevant when parsing an HTTP query string.


On Tue, Jul 4, 2017 at 4:55 PM, Jeffry Houser <[hidden email]> wrote:

> 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(parame
> ters);
>
>                 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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can I control the parameter order in an HTTPService Post?

Erik J. Thomas
In reply to this post by Jeffry Houser
Hey Jeffry:

I may be missing something in my understanding of your problem, but are you trying to send a body of parameters in the request payload? If so, I suggest you adopt a JSON or plain text approach, and build your params into the body/payload in the order you want by just building the string:

// JSON approach
httpService.contentType = "application/json";
httpService.send({ \"otherParameters\": \"Other Random Misc Data\", \"lastParameter\": \"LastOne\", \"firstParameter\": \"firstOne\", \"amount\": 100 });

The server endpoint will of course need to know how to parse the JSON, but your order will be preserved in the body of the request.

Another approach could be just to send the entire parameter string as you want it as the payload/body by just directly assigning it:

httpService.contentType = "text/html";
httpService.send("otherParameters=Other Random Misc Data&lastParameter=LastOne&firstParameter=firstOne&amount=100");

And parse the params on the server.

I so often have to bypass some of the cool functionality Flex provides to save me code when dealing with REST communication but with HTTP communication, everything is possible, since in the end an HTTP request is an HTTP request, it's generic, and unless your server cannot be changed to deal with a generic HTTP request (just treat the payload/body however you want) you can do anything you want by just building your requests without depending on utility classes. Sure you may have to write 5 more lines of code on the server, but that's often a lot easier than trying to fix something Flex doesn't do for you OOTB.

Erik

> On Jul 4, 2017, at 7:55 AM, Jeffry Houser <[hidden email]> wrote:
>
> 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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can I control the parameter order in an HTTPService Post?

Erik J. Thomas
Sorry, one very important typo in my example. This line should include the string in quotes so it's not interpreted as an object that will then be processed like you are seeing and you lose the order:

> httpService.send({ \"otherParameters\": \"Other Random Misc Data\", \"lastParameter\": \"LastOne\", \"firstParameter\": \"firstOne\", \"amount\": 100 });

Should be:

> httpService.send("{ \"otherParameters\": \"Other Random Misc Data\", \"lastParameter\": \"LastOne\", \"firstParameter\": \"firstOne\", \"amount\": 100 }");

And I agree with Javier, that servers should never rely on HTTP request parameter order, either in URL query params or in a collection of params sent in the body of a request. They should be specifically expecting "named" parameters and parsed accordingly. Your solution may be as simple as just eliminating that dependency on the server if you have access. Of course if you don't have any way to change the server endpoint logic then I suggest you breakpoint code and examine the contents of the payload after it processes your parameters and reproduce that with direct assignment of the body as text but in the order you want.

Erik

> On Jul 6, 2017, at 7:47 AM, Erik J. Thomas <[hidden email]> wrote:
>
> Hey Jeffry:
>
> I may be missing something in my understanding of your problem, but are you trying to send a body of parameters in the request payload? If so, I suggest you adopt a JSON or plain text approach, and build your params into the body/payload in the order you want by just building the string:
>
> // JSON approach
> httpService.contentType = "application/json";
> httpService.send({ \"otherParameters\": \"Other Random Misc Data\", \"lastParameter\": \"LastOne\", \"firstParameter\": \"firstOne\", \"amount\": 100 });
>
> The server endpoint will of course need to know how to parse the JSON, but your order will be preserved in the body of the request.
>
> Another approach could be just to send the entire parameter string as you want it as the payload/body by just directly assigning it:
>
> httpService.contentType = "text/html";
> httpService.send("otherParameters=Other Random Misc Data&lastParameter=LastOne&firstParameter=firstOne&amount=100");
>
> And parse the params on the server.
>
> I so often have to bypass some of the cool functionality Flex provides to save me code when dealing with REST communication but with HTTP communication, everything is possible, since in the end an HTTP request is an HTTP request, it's generic, and unless your server cannot be changed to deal with a generic HTTP request (just treat the payload/body however you want) you can do anything you want by just building your requests without depending on utility classes. Sure you may have to write 5 more lines of code on the server, but that's often a lot easier than trying to fix something Flex doesn't do for you OOTB.
>
> Erik
>
>> On Jul 4, 2017, at 7:55 AM, Jeffry Houser <[hidden email] <mailto:[hidden email]>> wrote:
>>
>> 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/ <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.dot-com-it.com/>
>> http://www.jeffryhouser.com
>> 203-379-0773
>>
>>
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can I control the parameter order in an HTTPService Post?

Jeffry Houser
In reply to this post by Javier Guerrero García
Thanks Kyle and Javier for their thoughts.

I was eventually able to do this using the lower level APIs of
URLRequest and URLLoader.  I also had to manually create the parameter
string.  Generically, the code is like this:


var parameters : String = '';
parameters += "firstParameter=firstOne&";
parameters += "amount=100&";
parameters += "otherParameters=Other Random Misc Data&";
parameters+= "lastParameter=LastOne";


var r:URLRequest = new URLRequest(yourURLHere);
r.data = parameters;
r.method = URLRequestMethod.POST;
r.contentType = "application/x-www-form-urlencoded";

var l:URLLoader = new URLLoader();
l.addEventListener(Event.COMPLETE, myResultMethod);
l.addEventListener(IOErrorEvent.IO_ERROR, myFailureMethod );
l.addEventListener(SecurityErrorEvent.SECURITY_ERROR, myFailureMethod );
l.load(r);

  Not as easy as using HTTPService, but functional and resolves this as
possible error cause when dealing with the vendor who built this API.

  Updated Stack Overflow Post:
https://stackoverflow.com/questions/44924870/can-i-control-the-parameter-order-in-an-httpservice-post

  My blog post on the issue:
https://www.jeffryhouser.com/index.cfm/2017/7/11/How-can-I-control-the-parameter-order-when-doing-a-HTTP-POST-call-from-Flex

  Thanks again!


On 7/5/2017 1:21 PM, Javier Guerrero García wrote:

> Hi Jeffrey!
>
> My 4 cents :)
>
> 1. Maybe defining the <mx:request> inside the <mx:HTTPservice>
> declaration (and just binding the contents) helps somewhat. Maybe not,
> but at least it's prettier :)
> http://help.adobe.com/en_US/Flex/4.0/AccessingData/WS2db454920e96a9e51e63e3d11c0bf69084-7fdc.html
>
> 2. Stupid one: try method="POST" (uppercase), just in case :)
>
> 3. According to the mx.rpc.httpAbstractOperation code, if
> typeof(parameters) == "object" it iterates and messes up with the
> order, but if it's not, it should just copy it to "paramsToSend"
> ("else paramsToSend=parameters;"). BUT, on some HTTP request
> implementations (for instance jQuery, not sure about flex), if you
> pass a string instead of a proper object as data, it "assumes" you
> want to make a GET instead of a POST. Are you 100% sure that, when you
> pass "parameters" as a string, you are issuing an empty *_POST_* request?
>
> 4. Instead of Flash network monitor, just get a quick PHP somewhere
> and monitor exactly what is arriving (and how) in your HTTP call (a
> simple <?php var_dump($_REQUEST); ?> would do). I'm not really sure if
> the sorting is done by the monitor itself, and I'm really perplexed
> about ObjectUtil.getClassInfo(parameters) does sort the object
> properties alphabetically (what a waste of CPU cycles!).
>
>
> P.S. And please, fire/kill the intern who programmed the server side
> trusting the order of the parameters.... I'm sure there is an RFC
> somewhere that you can throw at his face explicitly stating that
> params order should NOT be relevant when parsing an HTTP query string.
>
>
> On Tue, Jul 4, 2017 at 4:55 PM, Jeffry Houser <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     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 <tel:203-379-0773>
>
>

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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can I control the parameter order in an HTTPService Post?

kamcknig
Good job! Glad you got it to work.


Kyle McKnight
Senior UI Engineer - Accesso
602.515.1444 (M)

On Tue, Jul 11, 2017 at 9:44 AM, Jeffry Houser <[hidden email]>
wrote:

> Thanks Kyle and Javier for their thoughts.
>
> I was eventually able to do this using the lower level APIs of URLRequest
> and URLLoader.  I also had to manually create the parameter string.
> Generically, the code is like this:
>
>
> var parameters : String = '';
> parameters += "firstParameter=firstOne&";
> parameters += "amount=100&";
> parameters += "otherParameters=Other Random Misc Data&";
> parameters+= "lastParameter=LastOne";
>
>
> var r:URLRequest = new URLRequest(yourURLHere);
> r.data = parameters;
> r.method = URLRequestMethod.POST;
> r.contentType = "application/x-www-form-urlencoded";
>
> var l:URLLoader = new URLLoader();
> l.addEventListener(Event.COMPLETE, myResultMethod);
> l.addEventListener(IOErrorEvent.IO_ERROR, myFailureMethod );
> l.addEventListener(SecurityErrorEvent.SECURITY_ERROR, myFailureMethod );
> l.load(r);
>
>  Not as easy as using HTTPService, but functional and resolves this as
> possible error cause when dealing with the vendor who built this API.
>
>  Updated Stack Overflow Post: https://stackoverflow.com/ques
> tions/44924870/can-i-control-the-parameter-order-in-an-httpservice-post
>
>  My blog post on the issue: https://www.jeffryhouser.com/i
> ndex.cfm/2017/7/11/How-can-I-control-the-parameter-order-whe
> n-doing-a-HTTP-POST-call-from-Flex
>
>  Thanks again!
>
>
> On 7/5/2017 1:21 PM, Javier Guerrero García wrote:
>
>> Hi Jeffrey!
>>
>> My 4 cents :)
>>
>> 1. Maybe defining the <mx:request> inside the <mx:HTTPservice>
>> declaration (and just binding the contents) helps somewhat. Maybe not, but
>> at least it's prettier :)
>> http://help.adobe.com/en_US/Flex/4.0/AccessingData/WS2db4549
>> 20e96a9e51e63e3d11c0bf69084-7fdc.html
>>
>> 2. Stupid one: try method="POST" (uppercase), just in case :)
>>
>> 3. According to the mx.rpc.httpAbstractOperation code, if
>> typeof(parameters) == "object" it iterates and messes up with the order,
>> but if it's not, it should just copy it to "paramsToSend" ("else
>> paramsToSend=parameters;"). BUT, on some HTTP request implementations (for
>> instance jQuery, not sure about flex), if you pass a string instead of a
>> proper object as data, it "assumes" you want to make a GET instead of a
>> POST. Are you 100% sure that, when you pass "parameters" as a string, you
>> are issuing an empty *_POST_* request?
>>
>> 4. Instead of Flash network monitor, just get a quick PHP somewhere and
>> monitor exactly what is arriving (and how) in your HTTP call (a simple
>> <?php var_dump($_REQUEST); ?> would do). I'm not really sure if the sorting
>> is done by the monitor itself, and I'm really perplexed about
>> ObjectUtil.getClassInfo(parameters) does sort the object properties
>> alphabetically (what a waste of CPU cycles!).
>>
>>
>> P.S. And please, fire/kill the intern who programmed the server side
>> trusting the order of the parameters.... I'm sure there is an RFC somewhere
>> that you can throw at his face explicitly stating that params order should
>> NOT be relevant when parsing an HTTP query string.
>>
>>
>> On Tue, Jul 4, 2017 at 4:55 PM, Jeffry Houser <[hidden email]
>> <mailto:[hidden email]>> wrote:
>>
>>     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 <tel:203-379-0773>
>>
>>
>>
> --
> Jeffry Houser
> Technical Entrepreneur
> http://www.dot-com-it.com
> http://www.jeffryhouser.com
> 203-379-0773
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can I control the parameter order in an HTTPService Post?

Alex Harui-2
In reply to this post by Jeffry Houser
Hi Jeffry,

Good you got something to work.  I just had a thought that maybe you could
pass in an mx.utils.OrderedObject as the parameters and still use
HTTPService.

-Alex

On 7/11/17, 6:44 AM, "Jeffry Houser" <[hidden email]> wrote:

>Thanks Kyle and Javier for their thoughts.
>
>I was eventually able to do this using the lower level APIs of
>URLRequest and URLLoader.  I also had to manually create the parameter
>string.  Generically, the code is like this:
>
>
>var parameters : String = '';
>parameters += "firstParameter=firstOne&";
>parameters += "amount=100&";
>parameters += "otherParameters=Other Random Misc Data&";
>parameters+= "lastParameter=LastOne";
>
>
>var r:URLRequest = new URLRequest(yourURLHere);
>r.data = parameters;
>r.method = URLRequestMethod.POST;
>r.contentType = "application/x-www-form-urlencoded";
>
>var l:URLLoader = new URLLoader();
>l.addEventListener(Event.COMPLETE, myResultMethod);
>l.addEventListener(IOErrorEvent.IO_ERROR, myFailureMethod );
>l.addEventListener(SecurityErrorEvent.SECURITY_ERROR, myFailureMethod );
>l.load(r);
>
>  Not as easy as using HTTPService, but functional and resolves this as
>possible error cause when dealing with the vendor who built this API.
>
>  Updated Stack Overflow Post:
>https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstackover
>flow.com%2Fquestions%2F44924870%2Fcan-i-control-the-parameter-order-in-an-
>httpservice-post&data=02%7C01%7C%7Ced1ef0f084764fecd49108d4c862f8ac%7Cfa7b
>1b5a7b34438794aed2c178decee1%7C0%7C0%7C636353774788091375&sdata=LvnEYTMTwF
>lYPCZ7p%2Bu50adnHbdATVmP8ZPIQVxK3xU%3D&reserved=0
>
>  My blog post on the issue:
>https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.jeffr
>yhouser.com%2Findex.cfm%2F2017%2F7%2F11%2FHow-can-I-control-the-parameter-
>order-when-doing-a-HTTP-POST-call-from-Flex&data=02%7C01%7C%7Ced1ef0f08476
>4fecd49108d4c862f8ac%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C63635377
>4788091375&sdata=3jiLTEt%2FeZ2dwF2GgRyq0i1KPrCUAp1IhgAfPispLPY%3D&reserved
>=0
>
>  Thanks again!
>
>
>On 7/5/2017 1:21 PM, Javier Guerrero García wrote:
>> Hi Jeffrey!
>>
>> My 4 cents :)
>>
>> 1. Maybe defining the <mx:request> inside the <mx:HTTPservice>
>> declaration (and just binding the contents) helps somewhat. Maybe not,
>> but at least it's prettier :)
>>
>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fhelp.adob
>>e.com%2Fen_US%2FFlex%2F4.0%2FAccessingData%2FWS2db454920e96a9e51e63e3d11c
>>0bf69084-7fdc.html&data=02%7C01%7C%7Ced1ef0f084764fecd49108d4c862f8ac%7Cf
>>a7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636353774788091375&sdata=h0BEKg
>>IfRGJ%2FZ0bSng4jra5JYMSv5blS0JBgQ8GRZZE%3D&reserved=0
>>
>> 2. Stupid one: try method="POST" (uppercase), just in case :)
>>
>> 3. According to the mx.rpc.httpAbstractOperation code, if
>> typeof(parameters) == "object" it iterates and messes up with the
>> order, but if it's not, it should just copy it to "paramsToSend"
>> ("else paramsToSend=parameters;"). BUT, on some HTTP request
>> implementations (for instance jQuery, not sure about flex), if you
>> pass a string instead of a proper object as data, it "assumes" you
>> want to make a GET instead of a POST. Are you 100% sure that, when you
>> pass "parameters" as a string, you are issuing an empty *_POST_*
>>request?
>>
>> 4. Instead of Flash network monitor, just get a quick PHP somewhere
>> and monitor exactly what is arriving (and how) in your HTTP call (a
>> simple <?php var_dump($_REQUEST); ?> would do). I'm not really sure if
>> the sorting is done by the monitor itself, and I'm really perplexed
>> about ObjectUtil.getClassInfo(parameters) does sort the object
>> properties alphabetically (what a waste of CPU cycles!).
>>
>>
>> P.S. And please, fire/kill the intern who programmed the server side
>> trusting the order of the parameters.... I'm sure there is an RFC
>> somewhere that you can throw at his face explicitly stating that
>> params order should NOT be relevant when parsing an HTTP query string.
>>
>>
>> On Tue, Jul 4, 2017 at 4:55 PM, Jeffry Houser <[hidden email]
>> <mailto:[hidden email]>> wrote:
>>
>>     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&firstP
>>arameter=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
>>    
>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.dot-c
>>om-it.com&data=02%7C01%7C%7Ced1ef0f084764fecd49108d4c862f8ac%7Cfa7b1b5a7b
>>34438794aed2c178decee1%7C0%7C0%7C636353774788091375&sdata=abgmccKGMtx5gV0
>>as9JIlFopMaW5ojvyFuPwBEdMCtI%3D&reserved=0
>>    
>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jeffr
>>yhouser.com&data=02%7C01%7C%7Ced1ef0f084764fecd49108d4c862f8ac%7Cfa7b1b5a
>>7b34438794aed2c178decee1%7C0%7C0%7C636353774788091375&sdata=ALMfL5RGTLc5R
>>da5JbBYkbfYgByJNh%2FfVfdfuTa3AaY%3D&reserved=0
>>     203-379-0773 <tel:203-379-0773>
>>
>>
>
>--
>Jeffry Houser
>Technical Entrepreneur
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.dot-co
>m-it.com&data=02%7C01%7C%7Ced1ef0f084764fecd49108d4c862f8ac%7Cfa7b1b5a7b34
>438794aed2c178decee1%7C0%7C0%7C636353774788091375&sdata=abgmccKGMtx5gV0as9
>JIlFopMaW5ojvyFuPwBEdMCtI%3D&reserved=0
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jeffry
>houser.com&data=02%7C01%7C%7Ced1ef0f084764fecd49108d4c862f8ac%7Cfa7b1b5a7b
>34438794aed2c178decee1%7C0%7C0%7C636353774788091375&sdata=ALMfL5RGTLc5Rda5
>JbBYkbfYgByJNh%2FfVfdfuTa3AaY%3D&reserved=0
>203-379-0773
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can I control the parameter order in an HTTPService Post?

Jeffry Houser
Hi Alex,

  Interesting, that has potential.

  The potential problem is that the mx.rpc.httpAbstractOperation would
need an extension or rework, because it seems to copy my given
parameters into a paramsToSend object.  I never could find the code
where paremsToSend is added to the outgoing request, though.


On 7/11/2017 12:04 PM, Alex Harui wrote:

> Hi Jeffry,
>
> Good you got something to work.  I just had a thought that maybe you could
> pass in an mx.utils.OrderedObject as the parameters and still use
> HTTPService.
>
> -Alex
>
> On 7/11/17, 6:44 AM, "Jeffry Houser" <[hidden email]> wrote:
>
>> Thanks Kyle and Javier for their thoughts.
>>
>> I was eventually able to do this using the lower level APIs of
>> URLRequest and URLLoader.  I also had to manually create the parameter
>> string.  Generically, the code is like this:
>>
>>
>> var parameters : String = '';
>> parameters += "firstParameter=firstOne&";
>> parameters += "amount=100&";
>> parameters += "otherParameters=Other Random Misc Data&";
>> parameters+= "lastParameter=LastOne";
>>
>>
>> var r:URLRequest = new URLRequest(yourURLHere);
>> r.data = parameters;
>> r.method = URLRequestMethod.POST;
>> r.contentType = "application/x-www-form-urlencoded";
>>
>> var l:URLLoader = new URLLoader();
>> l.addEventListener(Event.COMPLETE, myResultMethod);
>> l.addEventListener(IOErrorEvent.IO_ERROR, myFailureMethod );
>> l.addEventListener(SecurityErrorEvent.SECURITY_ERROR, myFailureMethod );
>> l.load(r);
>>
>>   Not as easy as using HTTPService, but functional and resolves this as
>> possible error cause when dealing with the vendor who built this API.
>>
>>   Updated Stack Overflow Post:
>> https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstackover
>> flow.com%2Fquestions%2F44924870%2Fcan-i-control-the-parameter-order-in-an-
>> httpservice-post&data=02%7C01%7C%7Ced1ef0f084764fecd49108d4c862f8ac%7Cfa7b
>> 1b5a7b34438794aed2c178decee1%7C0%7C0%7C636353774788091375&sdata=LvnEYTMTwF
>> lYPCZ7p%2Bu50adnHbdATVmP8ZPIQVxK3xU%3D&reserved=0
>>
>>   My blog post on the issue:
>> https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.jeffr
>> yhouser.com%2Findex.cfm%2F2017%2F7%2F11%2FHow-can-I-control-the-parameter-
>> order-when-doing-a-HTTP-POST-call-from-Flex&data=02%7C01%7C%7Ced1ef0f08476
>> 4fecd49108d4c862f8ac%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C63635377
>> 4788091375&sdata=3jiLTEt%2FeZ2dwF2GgRyq0i1KPrCUAp1IhgAfPispLPY%3D&reserved
>> =0
>>
>>   Thanks again!
>>
>>
>> On 7/5/2017 1:21 PM, Javier Guerrero García wrote:
>>> Hi Jeffrey!
>>>
>>> My 4 cents :)
>>>
>>> 1. Maybe defining the <mx:request> inside the <mx:HTTPservice>
>>> declaration (and just binding the contents) helps somewhat. Maybe not,
>>> but at least it's prettier :)
>>>
>>> https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fhelp.adob
>>> e.com%2Fen_US%2FFlex%2F4.0%2FAccessingData%2FWS2db454920e96a9e51e63e3d11c
>>> 0bf69084-7fdc.html&data=02%7C01%7C%7Ced1ef0f084764fecd49108d4c862f8ac%7Cf
>>> a7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636353774788091375&sdata=h0BEKg
>>> IfRGJ%2FZ0bSng4jra5JYMSv5blS0JBgQ8GRZZE%3D&reserved=0
>>>
>>> 2. Stupid one: try method="POST" (uppercase), just in case :)
>>>
>>> 3. According to the mx.rpc.httpAbstractOperation code, if
>>> typeof(parameters) == "object" it iterates and messes up with the
>>> order, but if it's not, it should just copy it to "paramsToSend"
>>> ("else paramsToSend=parameters;"). BUT, on some HTTP request
>>> implementations (for instance jQuery, not sure about flex), if you
>>> pass a string instead of a proper object as data, it "assumes" you
>>> want to make a GET instead of a POST. Are you 100% sure that, when you
>>> pass "parameters" as a string, you are issuing an empty *_POST_*
>>> request?
>>>
>>> 4. Instead of Flash network monitor, just get a quick PHP somewhere
>>> and monitor exactly what is arriving (and how) in your HTTP call (a
>>> simple <?php var_dump($_REQUEST); ?> would do). I'm not really sure if
>>> the sorting is done by the monitor itself, and I'm really perplexed
>>> about ObjectUtil.getClassInfo(parameters) does sort the object
>>> properties alphabetically (what a waste of CPU cycles!).
>>>
>>>
>>> P.S. And please, fire/kill the intern who programmed the server side
>>> trusting the order of the parameters.... I'm sure there is an RFC
>>> somewhere that you can throw at his face explicitly stating that
>>> params order should NOT be relevant when parsing an HTTP query string.
>>>
>>>
>>> On Tue, Jul 4, 2017 at 4:55 PM, Jeffry Houser <[hidden email]
>>> <mailto:[hidden email]>> wrote:
>>>
>>>      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&firstP
>>> arameter=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
>>>      
>>> https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.dot-c
>>> om-it.com&data=02%7C01%7C%7Ced1ef0f084764fecd49108d4c862f8ac%7Cfa7b1b5a7b
>>> 34438794aed2c178decee1%7C0%7C0%7C636353774788091375&sdata=abgmccKGMtx5gV0
>>> as9JIlFopMaW5ojvyFuPwBEdMCtI%3D&reserved=0
>>>      
>>> https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jeffr
>>> yhouser.com&data=02%7C01%7C%7Ced1ef0f084764fecd49108d4c862f8ac%7Cfa7b1b5a
>>> 7b34438794aed2c178decee1%7C0%7C0%7C636353774788091375&sdata=ALMfL5RGTLc5R
>>> da5JbBYkbfYgByJNh%2FfVfdfuTa3AaY%3D&reserved=0
>>>      203-379-0773 <tel:203-379-0773>
>>>
>>>
>> --
>> Jeffry Houser
>> Technical Entrepreneur
>> https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.dot-co
>> m-it.com&data=02%7C01%7C%7Ced1ef0f084764fecd49108d4c862f8ac%7Cfa7b1b5a7b34
>> 438794aed2c178decee1%7C0%7C0%7C636353774788091375&sdata=abgmccKGMtx5gV0as9
>> JIlFopMaW5ojvyFuPwBEdMCtI%3D&reserved=0
>> https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jeffry
>> houser.com&data=02%7C01%7C%7Ced1ef0f084764fecd49108d4c862f8ac%7Cfa7b1b5a7b
>> 34438794aed2c178decee1%7C0%7C0%7C636353774788091375&sdata=ALMfL5RGTLc5Rda5
>> JbBYkbfYgByJNh%2FfVfdfuTa3AaY%3D&reserved=0
>> 203-379-0773
>>

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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can I control the parameter order in an HTTPService Post?

Alex Harui-2
I think I see paramsToSend get added in sendBody in
frameworks/projects/rpc/src/mx/rpc/http/AbstractOperation.as


I think I see it "serialize" the object into a string.  If OrderedObject
doesn't work, you can write your own Proxy subclass and control the order.

But interestingly, the code also looks like you can give
HTTPService.send() the request string instead of an object of name/value
pairs and it will use the string.

HTH,
-Alex

On 7/11/17, 9:16 AM, "Jeffry Houser" <[hidden email]> wrote:

>Hi Alex,
>
>  Interesting, that has potential.
>
>  The potential problem is that the mx.rpc.httpAbstractOperation would
>need an extension or rework, because it seems to copy my given
>parameters into a paramsToSend object.  I never could find the code
>where paremsToSend is added to the outgoing request, though.
>
>
>On 7/11/2017 12:04 PM, Alex Harui wrote:
>> Hi Jeffry,
>>
>> Good you got something to work.  I just had a thought that maybe you
>>could
>> pass in an mx.utils.OrderedObject as the parameters and still use
>> HTTPService.
>>
>> -Alex
>>
>> On 7/11/17, 6:44 AM, "Jeffry Houser" <[hidden email]> wrote:
>>
>>> Thanks Kyle and Javier for their thoughts.
>>>
>>> I was eventually able to do this using the lower level APIs of
>>> URLRequest and URLLoader.  I also had to manually create the parameter
>>> string.  Generically, the code is like this:
>>>
>>>
>>> var parameters : String = '';
>>> parameters += "firstParameter=firstOne&";
>>> parameters += "amount=100&";
>>> parameters += "otherParameters=Other Random Misc Data&";
>>> parameters+= "lastParameter=LastOne";
>>>
>>>
>>> var r:URLRequest = new URLRequest(yourURLHere);
>>> r.data = parameters;
>>> r.method = URLRequestMethod.POST;
>>> r.contentType = "application/x-www-form-urlencoded";
>>>
>>> var l:URLLoader = new URLLoader();
>>> l.addEventListener(Event.COMPLETE, myResultMethod);
>>> l.addEventListener(IOErrorEvent.IO_ERROR, myFailureMethod );
>>> l.addEventListener(SecurityErrorEvent.SECURITY_ERROR, myFailureMethod
>>>);
>>> l.load(r);
>>>
>>>   Not as easy as using HTTPService, but functional and resolves this as
>>> possible error cause when dealing with the vendor who built this API.
>>>
>>>   Updated Stack Overflow Post:
>>>
>>>https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstackov
>>>er
>>>
>>>flow.com%2Fquestions%2F44924870%2Fcan-i-control-the-parameter-order-in-a
>>>n-
>>>
>>>httpservice-post&data=02%7C01%7C%7Ced1ef0f084764fecd49108d4c862f8ac%7Cfa
>>>7b
>>>
>>>1b5a7b34438794aed2c178decee1%7C0%7C0%7C636353774788091375&sdata=LvnEYTMT
>>>wF
>>> lYPCZ7p%2Bu50adnHbdATVmP8ZPIQVxK3xU%3D&reserved=0
>>>
>>>   My blog post on the issue:
>>>
>>>https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.jef
>>>fr
>>>
>>>yhouser.com%2Findex.cfm%2F2017%2F7%2F11%2FHow-can-I-control-the-paramete
>>>r-
>>>
>>>order-when-doing-a-HTTP-POST-call-from-Flex&data=02%7C01%7C%7Ced1ef0f084
>>>76
>>>
>>>4fecd49108d4c862f8ac%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636353
>>>77
>>>
>>>4788091375&sdata=3jiLTEt%2FeZ2dwF2GgRyq0i1KPrCUAp1IhgAfPispLPY%3D&reserv
>>>ed
>>> =0
>>>
>>>   Thanks again!
>>>
>>>
>>> On 7/5/2017 1:21 PM, Javier Guerrero García wrote:
>>>> Hi Jeffrey!
>>>>
>>>> My 4 cents :)
>>>>
>>>> 1. Maybe defining the <mx:request> inside the <mx:HTTPservice>
>>>> declaration (and just binding the contents) helps somewhat. Maybe not,
>>>> but at least it's prettier :)
>>>>
>>>>
>>>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fhelp.ad
>>>>ob
>>>>
>>>>e.com%2Fen_US%2FFlex%2F4.0%2FAccessingData%2FWS2db454920e96a9e51e63e3d1
>>>>1c
>>>>
>>>>0bf69084-7fdc.html&data=02%7C01%7C%7Ced1ef0f084764fecd49108d4c862f8ac%7
>>>>Cf
>>>>
>>>>a7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636353774788091375&sdata=h0BE
>>>>Kg
>>>> IfRGJ%2FZ0bSng4jra5JYMSv5blS0JBgQ8GRZZE%3D&reserved=0
>>>>
>>>> 2. Stupid one: try method="POST" (uppercase), just in case :)
>>>>
>>>> 3. According to the mx.rpc.httpAbstractOperation code, if
>>>> typeof(parameters) == "object" it iterates and messes up with the
>>>> order, but if it's not, it should just copy it to "paramsToSend"
>>>> ("else paramsToSend=parameters;"). BUT, on some HTTP request
>>>> implementations (for instance jQuery, not sure about flex), if you
>>>> pass a string instead of a proper object as data, it "assumes" you
>>>> want to make a GET instead of a POST. Are you 100% sure that, when you
>>>> pass "parameters" as a string, you are issuing an empty *_POST_*
>>>> request?
>>>>
>>>> 4. Instead of Flash network monitor, just get a quick PHP somewhere
>>>> and monitor exactly what is arriving (and how) in your HTTP call (a
>>>> simple <?php var_dump($_REQUEST); ?> would do). I'm not really sure if
>>>> the sorting is done by the monitor itself, and I'm really perplexed
>>>> about ObjectUtil.getClassInfo(parameters) does sort the object
>>>> properties alphabetically (what a waste of CPU cycles!).
>>>>
>>>>
>>>> P.S. And please, fire/kill the intern who programmed the server side
>>>> trusting the order of the parameters.... I'm sure there is an RFC
>>>> somewhere that you can throw at his face explicitly stating that
>>>> params order should NOT be relevant when parsing an HTTP query string.
>>>>
>>>>
>>>> On Tue, Jul 4, 2017 at 4:55 PM, Jeffry Houser <[hidden email]
>>>> <mailto:[hidden email]>> wrote:
>>>>
>>>>      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&firs
>>>>tP
>>>> arameter=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
>>>>      
>>>>
>>>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.dot
>>>>-c
>>>>
>>>>om-it.com&data=02%7C01%7C%7Ced1ef0f084764fecd49108d4c862f8ac%7Cfa7b1b5a
>>>>7b
>>>>
>>>>34438794aed2c178decee1%7C0%7C0%7C636353774788091375&sdata=abgmccKGMtx5g
>>>>V0
>>>> as9JIlFopMaW5ojvyFuPwBEdMCtI%3D&reserved=0
>>>>      
>>>>
>>>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jef
>>>>fr
>>>>
>>>>yhouser.com&data=02%7C01%7C%7Ced1ef0f084764fecd49108d4c862f8ac%7Cfa7b1b
>>>>5a
>>>>
>>>>7b34438794aed2c178decee1%7C0%7C0%7C636353774788091375&sdata=ALMfL5RGTLc
>>>>5R
>>>> da5JbBYkbfYgByJNh%2FfVfdfuTa3AaY%3D&reserved=0
>>>>      203-379-0773 <tel:203-379-0773>
>>>>
>>>>
>>> --
>>> Jeffry Houser
>>> Technical Entrepreneur
>>>
>>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.dot-
>>>co
>>>
>>>m-it.com&data=02%7C01%7C%7Ced1ef0f084764fecd49108d4c862f8ac%7Cfa7b1b5a7b
>>>34
>>>
>>>438794aed2c178decee1%7C0%7C0%7C636353774788091375&sdata=abgmccKGMtx5gV0a
>>>s9
>>> JIlFopMaW5ojvyFuPwBEdMCtI%3D&reserved=0
>>>
>>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jeff
>>>ry
>>>
>>>houser.com&data=02%7C01%7C%7Ced1ef0f084764fecd49108d4c862f8ac%7Cfa7b1b5a
>>>7b
>>>
>>>34438794aed2c178decee1%7C0%7C0%7C636353774788091375&sdata=ALMfL5RGTLc5Rd
>>>a5
>>> JbBYkbfYgByJNh%2FfVfdfuTa3AaY%3D&reserved=0
>>> 203-379-0773
>>>
>
>--
>Jeffry Houser
>Technical Entrepreneur
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.dot-co
>m-it.com&data=02%7C01%7C%7Cb0438448d6174807fc3108d4c8783016%7Cfa7b1b5a7b34
>438794aed2c178decee1%7C0%7C0%7C636353865937125017&sdata=GaI1NHqx0jtaDQQP20
>XUZBcxyuVYUgXoMzXAXw9NAQk%3D&reserved=0
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jeffry
>houser.com&data=02%7C01%7C%7Cb0438448d6174807fc3108d4c8783016%7Cfa7b1b5a7b
>34438794aed2c178decee1%7C0%7C0%7C636353865937125017&sdata=Zfu7951H7w26%2Bl
>xHq81O%2Ft1j2FOs%2Fnifb94iHoazV6Q%3D&reserved=0
>203-379-0773
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can I control the parameter order in an HTTPService Post?

Jeffry Houser

On 7/11/2017 12:32 PM, Alex Harui wrote:
> But interestingly, the code also looks like you can give
> HTTPService.send() the request string instead of an object of name/value
> pairs and it will use the string.
The code does look like that, and it was the first thing I tried. The
string does not get added to the outgoing request; it just kind of
vanishes.


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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can I control the parameter order in an HTTPService Post?

Alex Harui-2
Ah yes.  It looks like the parameters might become the body.  It appears
there is a class called a SerializationFilter that might help you
translate the parameters to the right parts of the request.

From AbstractOperation:

if (filter != null)
        {
            // TODO: does this need to run on the array version of the
parameters
            ctype = filter.getRequestContentType(this, parameters, ctype);
            urlToUse = filter.serializeURL(this, parameters, urlToUse);
            parameters = filter.serializeBody(this, parameters);
        }



HTH,
-Alex

On 7/11/17, 11:03 AM, "Jeffry Houser" <[hidden email]> wrote:

>
>On 7/11/2017 12:32 PM, Alex Harui wrote:
>> But interestingly, the code also looks like you can give
>> HTTPService.send() the request string instead of an object of name/value
>> pairs and it will use the string.
>The code does look like that, and it was the first thing I tried. The
>string does not get added to the outgoing request; it just kind of
>vanishes.
>
>
>--
>Jeffry Houser
>Technical Entrepreneur
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.dot-co
>m-it.com&data=02%7C01%7C%7C9fdb398e607e41d6fb8708d4c8872791%7Cfa7b1b5a7b34
>438794aed2c178decee1%7C0%7C0%7C636353930201694821&sdata=4yHa0MXp0JwJ7fjY3Z
>gTz1kp5V9QO6T%2FooHdUFiIDHc%3D&reserved=0
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jeffry
>houser.com&data=02%7C01%7C%7C9fdb398e607e41d6fb8708d4c8872791%7Cfa7b1b5a7b
>34438794aed2c178decee1%7C0%7C0%7C636353930201704830&sdata=%2B9xHHB0xsmt8m7
>a92lJyFX9%2FDJQYEbYSUyQIIHRl030%3D&reserved=0
>203-379-0773
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can I control the parameter order in an HTTPService Post?

Jeffry Houser

  I looked into a Serialization Filter too.  Explicitly, the
serializeParameters() function.  Unfortunately, it returns a generic
object and is called before the parameters are processed in the
sendBody() function; meaning it had no affect.


On 7/11/2017 2:13 PM, Alex Harui wrote:

> Ah yes.  It looks like the parameters might become the body.  It appears
> there is a class called a SerializationFilter that might help you
> translate the parameters to the right parts of the request.
>
>  From AbstractOperation:
>
> if (filter != null)
>          {
>              // TODO: does this need to run on the array version of the
> parameters
>              ctype = filter.getRequestContentType(this, parameters, ctype);
>              urlToUse = filter.serializeURL(this, parameters, urlToUse);
>              parameters = filter.serializeBody(this, parameters);
>          }
>
>
>
> HTH,
> -Alex
>
> On 7/11/17, 11:03 AM, "Jeffry Houser" <[hidden email]> wrote:
>
>> On 7/11/2017 12:32 PM, Alex Harui wrote:
>>> But interestingly, the code also looks like you can give
>>> HTTPService.send() the request string instead of an object of name/value
>>> pairs and it will use the string.
>> The code does look like that, and it was the first thing I tried. The
>> string does not get added to the outgoing request; it just kind of
>> vanishes.
>>
>>
>> --
>> Jeffry Houser
>> Technical Entrepreneur
>> https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.dot-co
>> m-it.com&data=02%7C01%7C%7C9fdb398e607e41d6fb8708d4c8872791%7Cfa7b1b5a7b34
>> 438794aed2c178decee1%7C0%7C0%7C636353930201694821&sdata=4yHa0MXp0JwJ7fjY3Z
>> gTz1kp5V9QO6T%2FooHdUFiIDHc%3D&reserved=0
>> https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jeffry
>> houser.com&data=02%7C01%7C%7C9fdb398e607e41d6fb8708d4c8872791%7Cfa7b1b5a7b
>> 34438794aed2c178decee1%7C0%7C0%7C636353930201704830&sdata=%2B9xHHB0xsmt8m7
>> a92lJyFX9%2FDJQYEbYSUyQIIHRl030%3D&reserved=0
>> 203-379-0773
>>

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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can I control the parameter order in an HTTPService Post?

Alex Harui-2
I don't know this code at all, so I could be missing something, but I saw
this in AbstractOperation's sendBody:

if (filter != null)
        {
            // TODO: does this need to run on the array version of the
parameters
            ctype = filter.getRequestContentType(this, parameters, ctype);
            urlToUse = filter.serializeURL(this, parameters, urlToUse);
            parameters = filter.serializeBody(this, parameters);
        }

If you are doing a GET, I think you could use serializeURL to put the
parameters on the urlToUse in the order you want.  If the default
serializeURL doesn't do what you want, you would subclass it and override
serializeURL.


Of course, at that point, it might be easier to use URLLoader ;-)

-Alex


On 7/11/17, 1:15 PM, "Jeffry Houser" <[hidden email]> wrote:

>
>  I looked into a Serialization Filter too.  Explicitly, the
>serializeParameters() function.  Unfortunately, it returns a generic
>object and is called before the parameters are processed in the
>sendBody() function; meaning it had no affect.
>
>
>On 7/11/2017 2:13 PM, Alex Harui wrote:
>> Ah yes.  It looks like the parameters might become the body.  It appears
>> there is a class called a SerializationFilter that might help you
>> translate the parameters to the right parts of the request.
>>
>>  From AbstractOperation:
>>
>> if (filter != null)
>>          {
>>              // TODO: does this need to run on the array version of the
>> parameters
>>              ctype = filter.getRequestContentType(this, parameters,
>>ctype);
>>              urlToUse = filter.serializeURL(this, parameters, urlToUse);
>>              parameters = filter.serializeBody(this, parameters);
>>          }
>>
>>
>>
>> HTH,
>> -Alex
>>
>> On 7/11/17, 11:03 AM, "Jeffry Houser" <[hidden email]> wrote:
>>
>>> On 7/11/2017 12:32 PM, Alex Harui wrote:
>>>> But interestingly, the code also looks like you can give
>>>> HTTPService.send() the request string instead of an object of
>>>>name/value
>>>> pairs and it will use the string.
>>> The code does look like that, and it was the first thing I tried. The
>>> string does not get added to the outgoing request; it just kind of
>>> vanishes.
>>>
>>>
>>> --
>>> Jeffry Houser
>>> Technical Entrepreneur
>>>
>>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.dot-
>>>co
>>>
>>>m-it.com&data=02%7C01%7C%7C9fdb398e607e41d6fb8708d4c8872791%7Cfa7b1b5a7b
>>>34
>>>
>>>438794aed2c178decee1%7C0%7C0%7C636353930201694821&sdata=4yHa0MXp0JwJ7fjY
>>>3Z
>>> gTz1kp5V9QO6T%2FooHdUFiIDHc%3D&reserved=0
>>>
>>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jeff
>>>ry
>>>
>>>houser.com&data=02%7C01%7C%7C9fdb398e607e41d6fb8708d4c8872791%7Cfa7b1b5a
>>>7b
>>>
>>>34438794aed2c178decee1%7C0%7C0%7C636353930201704830&sdata=%2B9xHHB0xsmt8
>>>m7
>>> a92lJyFX9%2FDJQYEbYSUyQIIHRl030%3D&reserved=0
>>> 203-379-0773
>>>
>
>--
>Jeffry Houser
>Technical Entrepreneur
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.dot-co
>m-it.com&data=02%7C01%7C%7Ce0b51fcdffd245b92a5f08d4c89fa97e%7Cfa7b1b5a7b34
>438794aed2c178decee1%7C0%7C0%7C636354035468010487&sdata=ee0SL0eI4x3XAHwCes
>o2KB70P1fskNgc5Gj8Tunl6kg%3D&reserved=0
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jeffry
>houser.com&data=02%7C01%7C%7Ce0b51fcdffd245b92a5f08d4c89fa97e%7Cfa7b1b5a7b
>34438794aed2c178decee1%7C0%7C0%7C636354035468010487&sdata=rYiyQHpgw2pNr3X0
>fr%2BiHE%2BuTEzh0fIF7iNCosT7Kp8%3D&reserved=0
>203-379-0773
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can I control the parameter order in an HTTPService Post?

Harbs
I gave up on HTTPService long ago. It’s nice how simple it is to use, but it’s sooo limiting.

I use URLLoader for just about everything. I wrapped it in my own classes that do everything I need including tracking status, parsing responses and error responses, progress, dispatching custom events (or callbacks) and multi-part uploads.

> On Jul 12, 2017, at 12:05 AM, Alex Harui <[hidden email]> wrote:
>
> Of course, at that point, it might be easier to use URLLoader ;-)

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can I control the parameter order in an HTTPService Post?

Jeffry Houser
In reply to this post by Alex Harui-2
  Not doing a get, doing a post, FWIW.


On 7/11/2017 5:05 PM, Alex Harui wrote:

> I don't know this code at all, so I could be missing something, but I saw
> this in AbstractOperation's sendBody:
>
> if (filter != null)
>          {
>              // TODO: does this need to run on the array version of the
> parameters
>              ctype = filter.getRequestContentType(this, parameters, ctype);
>              urlToUse = filter.serializeURL(this, parameters, urlToUse);
>              parameters = filter.serializeBody(this, parameters);
>          }
>
> If you are doing a GET, I think you could use serializeURL to put the
> parameters on the urlToUse in the order you want.  If the default
> serializeURL doesn't do what you want, you would subclass it and override
> serializeURL.
>
>
> Of course, at that point, it might be easier to use URLLoader ;-)
>
> -Alex
>
>
> On 7/11/17, 1:15 PM, "Jeffry Houser" <[hidden email]> wrote:
>
>>   I looked into a Serialization Filter too.  Explicitly, the
>> serializeParameters() function.  Unfortunately, it returns a generic
>> object and is called before the parameters are processed in the
>> sendBody() function; meaning it had no affect.
>>
>>
>> On 7/11/2017 2:13 PM, Alex Harui wrote:
>>> Ah yes.  It looks like the parameters might become the body.  It appears
>>> there is a class called a SerializationFilter that might help you
>>> translate the parameters to the right parts of the request.
>>>
>>>   From AbstractOperation:
>>>
>>> if (filter != null)
>>>           {
>>>               // TODO: does this need to run on the array version of the
>>> parameters
>>>               ctype = filter.getRequestContentType(this, parameters,
>>> ctype);
>>>               urlToUse = filter.serializeURL(this, parameters, urlToUse);
>>>               parameters = filter.serializeBody(this, parameters);
>>>           }
>>>
>>>
>>>
>>> HTH,
>>> -Alex
>>>
>>> On 7/11/17, 11:03 AM, "Jeffry Houser" <[hidden email]> wrote:
>>>
>>>> On 7/11/2017 12:32 PM, Alex Harui wrote:
>>>>> But interestingly, the code also looks like you can give
>>>>> HTTPService.send() the request string instead of an object of
>>>>> name/value
>>>>> pairs and it will use the string.
>>>> The code does look like that, and it was the first thing I tried. The
>>>> string does not get added to the outgoing request; it just kind of
>>>> vanishes.
>>>>
>>>>
>>>> --
>>>> Jeffry Houser
>>>> Technical Entrepreneur
>>>>
>>>> https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.dot-
>>>> co
>>>>
>>>> m-it.com&data=02%7C01%7C%7C9fdb398e607e41d6fb8708d4c8872791%7Cfa7b1b5a7b
>>>> 34
>>>>
>>>> 438794aed2c178decee1%7C0%7C0%7C636353930201694821&sdata=4yHa0MXp0JwJ7fjY
>>>> 3Z
>>>> gTz1kp5V9QO6T%2FooHdUFiIDHc%3D&reserved=0
>>>>
>>>> https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jeff
>>>> ry
>>>>
>>>> houser.com&data=02%7C01%7C%7C9fdb398e607e41d6fb8708d4c8872791%7Cfa7b1b5a
>>>> 7b
>>>>
>>>> 34438794aed2c178decee1%7C0%7C0%7C636353930201704830&sdata=%2B9xHHB0xsmt8
>>>> m7
>>>> a92lJyFX9%2FDJQYEbYSUyQIIHRl030%3D&reserved=0
>>>> 203-379-0773
>>>>
>> --
>> Jeffry Houser
>> Technical Entrepreneur
>> https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.dot-co
>> m-it.com&data=02%7C01%7C%7Ce0b51fcdffd245b92a5f08d4c89fa97e%7Cfa7b1b5a7b34
>> 438794aed2c178decee1%7C0%7C0%7C636354035468010487&sdata=ee0SL0eI4x3XAHwCes
>> o2KB70P1fskNgc5Gj8Tunl6kg%3D&reserved=0
>> https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jeffry
>> houser.com&data=02%7C01%7C%7Ce0b51fcdffd245b92a5f08d4c89fa97e%7Cfa7b1b5a7b
>> 34438794aed2c178decee1%7C0%7C0%7C636354035468010487&sdata=rYiyQHpgw2pNr3X0
>> fr%2BiHE%2BuTEzh0fIF7iNCosT7Kp8%3D&reserved=0
>> 203-379-0773
>>

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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can I control the parameter order in an HTTPService Post?

Alex Harui-2
OK, I'm not as familiar with POST, but it looks like the filter controls
the urlToUse and the message body.

Of course, I could be wrong...
-Alex

On 7/12/17, 6:36 AM, "Jeffry Houser" <[hidden email]> wrote:

>  Not doing a get, doing a post, FWIW.
>
>
>On 7/11/2017 5:05 PM, Alex Harui wrote:
>> I don't know this code at all, so I could be missing something, but I
>>saw
>> this in AbstractOperation's sendBody:
>>
>> if (filter != null)
>>          {
>>              // TODO: does this need to run on the array version of the
>> parameters
>>              ctype = filter.getRequestContentType(this, parameters,
>>ctype);
>>              urlToUse = filter.serializeURL(this, parameters, urlToUse);
>>              parameters = filter.serializeBody(this, parameters);
>>          }
>>
>> If you are doing a GET, I think you could use serializeURL to put the
>> parameters on the urlToUse in the order you want.  If the default
>> serializeURL doesn't do what you want, you would subclass it and
>>override
>> serializeURL.
>>
>>
>> Of course, at that point, it might be easier to use URLLoader ;-)
>>
>> -Alex
>>
>>
>> On 7/11/17, 1:15 PM, "Jeffry Houser" <[hidden email]> wrote:
>>
>>>   I looked into a Serialization Filter too.  Explicitly, the
>>> serializeParameters() function.  Unfortunately, it returns a generic
>>> object and is called before the parameters are processed in the
>>> sendBody() function; meaning it had no affect.
>>>
>>>
>>> On 7/11/2017 2:13 PM, Alex Harui wrote:
>>>> Ah yes.  It looks like the parameters might become the body.  It
>>>>appears
>>>> there is a class called a SerializationFilter that might help you
>>>> translate the parameters to the right parts of the request.
>>>>
>>>>   From AbstractOperation:
>>>>
>>>> if (filter != null)
>>>>           {
>>>>               // TODO: does this need to run on the array version of
>>>>the
>>>> parameters
>>>>               ctype = filter.getRequestContentType(this, parameters,
>>>> ctype);
>>>>               urlToUse = filter.serializeURL(this, parameters,
>>>>urlToUse);
>>>>               parameters = filter.serializeBody(this, parameters);
>>>>           }
>>>>
>>>>
>>>>
>>>> HTH,
>>>> -Alex
>>>>
>>>> On 7/11/17, 11:03 AM, "Jeffry Houser" <[hidden email]> wrote:
>>>>
>>>>> On 7/11/2017 12:32 PM, Alex Harui wrote:
>>>>>> But interestingly, the code also looks like you can give
>>>>>> HTTPService.send() the request string instead of an object of
>>>>>> name/value
>>>>>> pairs and it will use the string.
>>>>> The code does look like that, and it was the first thing I tried. The
>>>>> string does not get added to the outgoing request; it just kind of
>>>>> vanishes.
>>>>>
>>>>>
>>>>> --
>>>>> Jeffry Houser
>>>>> Technical Entrepreneur
>>>>>
>>>>>
>>>>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.do
>>>>>t-
>>>>> co
>>>>>
>>>>>
>>>>>m-it.com&data=02%7C01%7C%7C9fdb398e607e41d6fb8708d4c8872791%7Cfa7b1b5a
>>>>>7b
>>>>> 34
>>>>>
>>>>>
>>>>>438794aed2c178decee1%7C0%7C0%7C636353930201694821&sdata=4yHa0MXp0JwJ7f
>>>>>jY
>>>>> 3Z
>>>>> gTz1kp5V9QO6T%2FooHdUFiIDHc%3D&reserved=0
>>>>>
>>>>>
>>>>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.je
>>>>>ff
>>>>> ry
>>>>>
>>>>>
>>>>>houser.com&data=02%7C01%7C%7C9fdb398e607e41d6fb8708d4c8872791%7Cfa7b1b
>>>>>5a
>>>>> 7b
>>>>>
>>>>>
>>>>>34438794aed2c178decee1%7C0%7C0%7C636353930201704830&sdata=%2B9xHHB0xsm
>>>>>t8
>>>>> m7
>>>>> a92lJyFX9%2FDJQYEbYSUyQIIHRl030%3D&reserved=0
>>>>> 203-379-0773
>>>>>
>>> --
>>> Jeffry Houser
>>> Technical Entrepreneur
>>>
>>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.dot-
>>>co
>>>
>>>m-it.com&data=02%7C01%7C%7Ce0b51fcdffd245b92a5f08d4c89fa97e%7Cfa7b1b5a7b
>>>34
>>>
>>>438794aed2c178decee1%7C0%7C0%7C636354035468010487&sdata=ee0SL0eI4x3XAHwC
>>>es
>>> o2KB70P1fskNgc5Gj8Tunl6kg%3D&reserved=0
>>>
>>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jeff
>>>ry
>>>
>>>houser.com&data=02%7C01%7C%7Ce0b51fcdffd245b92a5f08d4c89fa97e%7Cfa7b1b5a
>>>7b
>>>
>>>34438794aed2c178decee1%7C0%7C0%7C636354035468010487&sdata=rYiyQHpgw2pNr3
>>>X0
>>> fr%2BiHE%2BuTEzh0fIF7iNCosT7Kp8%3D&reserved=0
>>> 203-379-0773
>>>
>
>--
>Jeffry Houser
>Technical Entrepreneur
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jeffry
>houser.com&data=02%7C01%7C%7C7287d851148842182e8508d4c92b501f%7Cfa7b1b5a7b
>34438794aed2c178decee1%7C0%7C0%7C636354635240947977&sdata=3Hj0pBg4DrS8TVCd
>JqbYekiNRG3Z7fFh69hqHqMw1xY%3D&reserved=0
>203-379-0773
>

Loading...