views:

37

answers:

1

Hello,

I have a function fooA(valueA1, valueA2) which calls web method myWSA(). Upon reeiving the result, it invokes a result handler which inturn calls another web service myWSB(value2). I want to know how I can pass/access this value2 into foo2. These values: value1 and value2 are dependent on the button clicled.

private function fooA(valueA1:int, valueA2:int){
     callResponder.token = myWSA(valueA1);
}

private function myWSA_resultHandler(event:ResultEvent ) {
     myWSB(value2); //----------> I want to use the parameter, value2, passed in fooA here.

}


<fx:Declarations>
<s:WebService id = "myWebService"
                      wsdl = "http://MyWebService?wsdl"
                      fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)">
            <s:operation name = "myWSA"
                         result= "myWSA_resultHandler(event)"/>

</s:WebService>
<s:CallResponder id = "callResponder" />
</fx:Declarations>

<s:Button id = "button1"
          label="Button1"
       click = "fooA(val1, val2)"/>
<s:Button id = "button2"
          label="Button2"
       click = "fooA(val3, val4)"/>
A: 

You can't access an argument from one method inside another method. Go back to the source and access the original value.

If your able to assume that Val1 and val2 won't change between the start of the first call and the second call, just access them normally using this.val1 .

If you want to assume the values may change, or are call specific, then you'll want to store the values at the time of the first call, under the assumption that they may change you'll need to write a mechanism to keep track of ongoing calls and their relevant associated properties.

I question what you're trying to accomplish, though. Wouldn't it be better to wrap up web service 1 and web service 2 into the same call?

www.Flextras.com
I need to call web service 2 only when result of web service 1 is received, and thus, I am calling web service 2 in the result handler of web service1. This prevents me from wrapping web service 1 and web service 2 in the same call, unless there is a way that I am missing.
H P
I don't understand why you need to call Web Service 2 after Web Service 1, especially since you have described no client interaction between the two actions. Youv'e described no reason why you can't chain these two things together on the server.
www.Flextras.com
WebService 1 is to write into server and WebService 2 is to read from the server. Only when write is done, I want to call read for which I am using result event of WebService 1 to call Web Service 2.
H P
And why can't you read and write in the same service call? I've seen it done all the time. Is there any reason some of my original suggestions will not work for you/
www.Flextras.com
The web services are provided to me, I cant make changes to them. Is there any work around?
H P
Yes, I described two work-arounds in my original answer. Is there any reason those won't work?
www.Flextras.com