1 Reply Latest reply on Feb 5, 2008 11:33 AM by ntsiii

    Dynamic parameter list in a webservice MXML request

    loicfrering
      Hello,
      I'd like to dynamically generate the request parameter of a web service like that :

      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
      <mx:WebService id="pegasus" wsdl=" http://myservice?wsdl" useProxy="false" load="headers();">
      <mx:operation name=" myOperation ">
      <mx:request>
      <arg0>
      <parameter1>{parameter1Input.text}</parameter1>
      <parameter2>{parameter2Input.text}</parameter2>
      <listParameter3>
      <element1>????</element1>
      <element1>????</element1>
      <element1>????</element1>
      <element1>????</element1>
      ………………………………………………
      </listParameter3>
      </arg0>
      </mx:request>
      </mx:operation>
      </mx:WebService>

      So I'd like to know how to generate the list, with an unknown number of elements, from a datagrid for example.
      I tried to generate a XML from a variable like that :

      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
      <mx:WebService id="pegasus" wsdl=" http://myservice?wsdl" useProxy="false">
      <mx:operation name="myOperation">
      <mx:request>
      <arg0>
      <parameter1>{parameter1Input.text}</parameter1>
      <parameter2>{parameter2Input.text}</parameter2>
      <listParameter3>
      {myList}
      </listParameter3>
      </arg0>
      </mx:request>
      </mx:operation>
      </mx:WebService>
      <mx:Script>
      <![CDATA[
      public var myList:XML;

      public function essai():XML {

      // call this function before send
      // populate myList from formulary
      }
      ]]>
      </mx:Script>

      But it didn't work, can you help me ?
        • 1. Re: Dynamic parameter list in a webservice MXML request
          ntsiii Level 3
          This current problem with the forum makes code almost impossible to read. Hope they fix it soon.

          You can build the request object in AS code. Use mxml to declare the webservice. Then in a function do something like this example:

          //Sets up and invokes werservice call
          private function getEmployees():Void
          {
          var sOperationName:String = "getList"; //Put the operation name in a var
          var oRequest:Object = employeeWS[sOperationName].request; //get a reference to the operations request object
          oRequest.deptId = dept.selectedItem.data; //put the deptId Name/Value pair in the request
          var call = employeeWS[sOperationName].send(); /Invoke the call
          }

          Tracy