2 Replies Latest reply on Jul 31, 2008 1:38 PM by batmitra

    consecutive <webservice>.send()

      Hello forum,

      I'm new at Flex and ActionScript and I am in trouble with Web Service Consumption. In my application, I need to call several times to the same Web Service but with one different request parameter.

      The thing is, that once performed all the .send(), the resultHandler is called, but always with the last value I gave to that request parameter, so the result is always the same.

      I paste some of the code:

      [..]
      employeeID = "00005001";
      wsGetEmployeeData.EmployeeGetdata.send();
      employeeID = "00005002";
      wsGetEmployeeData.EmployeeGetdata.send();
      [..]
      private function resultGetEmployeeData(event:ResultEvent):void{
      xmlEmpData= wsGetEmployeeData.EmployeeGetdata.lastResult;
      [..]
      <mx:WebService id="wsGetEmployeeData" wsdl="url">
      <mx:operation name="EmployeeGetdata"
      resultFormat="e4x"
      result="resultGetEmployeeData(event);"
      fault="faultGetEmployeeData(event);">
      <mx:request>
      <EmployeeId>{employeeID}</EmployeeId>
      </mx:request>
      </mx:operation>
      </mx:WebService>
      [..]

      Does anyone have an idea of how to call the Same Webservice?

      Thank you,
      toni
        • 1. Re: consecutive &lt;webservice&gt;.send()
          Level 7
          It is my understanding that each WebService.send() will result in your
          result handler being called. It is being called twice, but you are
          probably only seeing the results of the second call as you are
          overwriting the xmlEmpData variable.

          I think that you can use AsyncTokens to track the different requests.

          Hope this is some help

          Martyn


          tonnimontana wrote:
          > Hello forum,
          >
          > I'm new at Flex and ActionScript and I am in trouble with Web Service
          > Consumption. In my application, I need to call several times to the same Web
          > Service but with one different request parameter.
          >
          > The thing is, that once performed all the .send(), the resultHandler is
          > called, but always with the last value I gave to that request parameter, so the
          > result is always the same.
          >
          > I paste some of the code:
          >
          > [..]
          > employeeID = "00005001";
          > wsGetEmployeeData.EmployeeGetdata.send();
          > employeeID = "00005002";
          > wsGetEmployeeData.EmployeeGetdata.send();
          > [..]
          > private function resultGetEmployeeData(event:ResultEvent):void{
          > xmlEmpData= wsGetEmployeeData.EmployeeGetdata.lastResult;
          > [..]
          > <mx:WebService id="wsGetEmployeeData" wsdl="url">
          > <mx:operation name="EmployeeGetdata"
          > resultFormat="e4x"
          > result="resultGetEmployeeData(event);"
          > fault="faultGetEmployeeData(event);">
          > <mx:request>
          > <EmployeeId>{employeeID}</EmployeeId>
          > </mx:request>
          > </mx:operation>
          > </mx:WebService>
          > [..]
          >
          > Does anyone have an idea of how to call the Same Webservice?
          >
          > Thank you,
          > toni
          >
          >
          • 2. Re: consecutive &lt;webservice&gt;.send()
            batmitra Level 1
            hi
            why are you calling your webservices like that? there's an much easier way to do that:
            like this

            if you have you webservice definition in mxm like

            <mx:webservice name="youwebservice" wsdl="yourwebservice path?wsdl">
            <mx:operation name="youroperationname" result="your result handler function"/>
            </mx:webservice>

            then in actionscript you can call it like:

            yourwebservice.youroperationname(yourparameter)

            and this wil return each time a diferente result depending on what you send as parameter.

            the .send way is used with httpservice because it doesn't have methods defined