2 Replies Latest reply on Feb 22, 2011 9:47 AM by Saha_Amitava

    Dynamically add some elements in WebService operation request

    Saha_Amitava

      Hi, 

       

      I have a WebService element defined in my mxml which use to make soap calls. 

      I need to dynamically add some repeating groups for action (dependent on action) in the following example. 

      How can I add this in Action Script section? Can I access the WebService  by id userRequest and specify " 

      userRequest.operations.DoAction.request.DoItemActionRequest.action.requiresAdditionItems.n ameValuePair.name = "SomeName"; 

      userRequest.operations.DoAction.request.DoItemActionRequest.action.requiresAdditionItems.n ameValuePair.name = "SomeValue";  

       

      <mx:WebService  id="userRequest" wsdl="{Application.application.wsdl}" > 

           <mx:operation name="DoAction" resultFormat="object" 

            fault="faultHandler(event)" 

            result="DoActionHandler(evnt)">

              <mx:request> 

                <DoActionRequest> 

                   <userId>{Application.application.userID}</userId> 

                    <action> 

                       <actionId>{selectedItem.actionId}</actionId> 

                   </action> 

                </DoActionRequest> 

               </mx:request> 

             </mx:operation> 

      </mx:WebService>

       

       

      Thanks,

      Amitava


        • 1. Re: Dynamically add some elements in WebService operation request
          miguel8312 Level 3

          ok well what you can do is something like this.

          <mx:WebService id="ws" wsdl="http://localhost:3960/WebSite6/Service.asmx?WSDL" fault="fault(event)"> 
           
          <mx:operation 
           name="Process_Upload" 
           resultFormat="object" 
           result="Process_Upload(event)"/>
          


          then in actionscript you can reference like this.

          ws.process_upload();


          then you will also need a result handler for the xml coming back from the webservice.

          in my case.

           

          public function Process_Upload(event:ResultEvent):void{
          
          }
          

          then optionally you can have a function to handle errors like such.

          // need to make these alert boxes better looking.
                  private function fault(event:FaultEvent):void {
                         // Oppps some error occured
                         Alert.show(event.toString(), "upload webservice failed.");
                    }
          
          
          
          • 2. Re: Dynamically add some elements in WebService operation request
            Saha_Amitava Level 1

            Hi miguel8312,

             

            Thanks for your suggestion. I understand the steps you explained for defining, calling and processing the result from a webservice from a MXML body.

             

            My query is specifically, can I modify the webservice request defination from AS function before making the call?

            In my example, if I need to dynamically add a name value pair for <action> tag (e.g. actionParam ), how do I do that?

             

             

            Thanks,

            Amitava