4 Replies Latest reply on Oct 11, 2007 1:02 PM by furta

    posting an array parameter using HTTPService

      I am trying to post a set of xmls using the HTTPService. the code looks like this

      public function saveListDelegate( responder:IResponder, xml1:String, xml2:String){

      var variables :URLVariables;
      variables.xmlString = xml1;
      variables.xmlString = xml2;
      //trying to post http://localhost/app/data/xmlSaver.jsp?xmlString=<name id="1">...</name>&xmlString =<name id="2">...</name>
      var _service:HTTPService = ServiceLocator.getInstance().getHTTPService( "xmlSaver" );
      _service.requestTimeout = 3000;
      _service.method = "POST";
      _responder = responder;

      var call:AsyncToken = _service.send(variables);
      call.addResponder( _responder );

      But this piece of code only posts one of the xmls and does not send the xmlString as a array of Strings.

      does anybody know how to do this...
        • 1. Re: posting an array parameter using HTTPService
          atta707 Level 2
          I think URLVariables class is meant to be used with URLRequest; from the docs:

          The URLVariables class allows you to transfer variables between an application and a server. Use URLVariables objects with methods of the URLLoader class, with the data property of the URLRequest class, and with flash.net package functions.

          as for the HTTPRequest based requests try this:

          var params:Object = new Object();
          o.p1 = "hello";
          o.p2 = "world";



          • 2. Re: posting an array parameter using HTTPService
            furta Level 1
            "var params:Object = new Object();
            o.p1 = "hello";
            o.p2 = "world";"

            I have tried this too and it ends up with the same result. the only reference I could find anywhere on the web ( http://jessewarden.com/2007/06/page/2) says this.

            HTTPService has 2 ways to give it stuff; either set it’s request property before sending or pass it in the send function. However, if a WebSevice accepts this:


            Well… you’re kind of screwed. There is only 1 param…

            var o = {};
            o.param = “uno”;
            o.param = “dos”; // overwrites uno
            o.param = “tres”; // overwrites dos… all are same param variable

            I tried my best to hack the IMessage object that’s associated with an HTTPService AsyncToken (mx.messaging.messages.HTTPServiceMessage I think), but no go. What to do? Uber l33t h@x of course!

            I am looking for somebody to confirm my fears...

            Thanks for the reply...
            • 3. Re: posting an array parameter using HTTPService
              atta707 Level 2
              I'm using Flex Builder 3 Beta 2 and have a JEE application on the server side. Here is *working* code example from my project:

              var o:Object = new Object();
              var submodels:Array = new Array();


              o.submodels = submodels;


              on the service side I get a an array of 'submode' request parameter.

              hope this helps.

              • 4. Re: posting an array parameter using HTTPService
                furta Level 1
                Thanks Atta.

                Already tried that.. In flex 2 the value on the server is a comma separated list of values.


                o.submodels = submodels;


                in this case the server recieves a string called submodels as "1,2,3,4,5"

                Well that should explain most of it. I guess it was fixed for flex3...