I'm trying to learn how to use the WebService class in ActionScript
3.0 as part of a Flex 2.0 XML tutorial I'm writing for my blog
(www.brucephillips.name/blog).

I'm having great difficulty getting the code below to work.  I've read
throught the RPC components section of the Flex 2 Developer's Guide
and the WebServices description in the ActionScript 3.0 Reference. 
I've also search through FlexCoders and Google.  The references are
extremely POOR in giving working examples of how to use class WebService.

The below code uses the currency exchange rate WebService described
here: http://www.xmethods.net (under demo services).  I know the
WebService works as I've tested it using ColdFusion.

Any help you can provide me would be much appreciated and I will
mention your assistance in my blog.  The problem appears that my
resultHandler function is never called as the test in my TextArea
component does not change.


Here is the code:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute" creationComplete="useWebService()">
        <mx:Script>
        <![CDATA[
                import mx.rpc.soap.LoadEvent;
        
                
        import mx.controls.Alert;
        import mx.rpc.events.ResultEvent;
        import mx.rpc.events.FaultEvent;
        
        
        import mx.rpc.soap.WebService;
          
         public function useWebService():void {
                
            var service:WebService = new WebService();
            service.wsdl =
"http://www.xmethods.net/sd/2001/CurrencyExchangeService.wsdl";
            service.getRate.addEventListener("result", resultHandler);
            service.getRate.addEventListener("fault", faultHandler);
            service.loadWSDL();
            service.getRate("canada", "united states");
            
                        }
                        
                
                        
        public function resultHandler(event:ResultEvent):void               
                  {
                        
                        myTextArea.text = "Result returned";
                        
                }
                
                public function faultHandler(event:FaultEvent):void {
                        
                        Alert.show("fault: "+ event.toString());
                
                }
         
         
         ]]>
    </mx:Script>
        <mx:TextArea x="134" y="65" id="myTextArea" text="getting service"/>
</mx:Application>

Thanks in advance.

Bruce Phillips






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcoders/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to