EX02

Flexから、s2axis-examplesのEX02を呼び出してみる。

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
  <mx:Button label="HelloTest" y="10" left="10" click="testClick()"/>
  <mx:Label y="12" text="result" right="10" left="96" id="resultLabel"/>

  <mx:WebService id="webService" wsdl="http://localhost:8080/s2axis-examples/services/Hello?wsdl">
    <mx:operation name="say" result="testResult(event)" fault="testFault(event)">
    </mx:operation>
  </mx:WebService>

  <mx:Script>
    <![CDATA[
      import mx.controls.Alert;
      import mx.rpc.events.ResultEvent;

      private function testClick(): void {
        webService.say();
      }
      
      private function testResult(event: ResultEvent): void {
        resultLabel.text = event.result as String;
      }

      private function testFault(event: Event): void {
        Alert.show(event.toString());
      }
    ]]>
  </mx:Script>
</mx:Application>