EX03 その2

を使ってみた。送信はOKなんだけど、受信はそのままバインドできないみたい。

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
  <mx:Button label="BookshelfTest" y="10" left="10" click="testClick()"/>

  <mx:WebService id="webService" wsdl="http://localhost:8080/s2axis-examples/services/Bookshelf?wsdl">
    <mx:operation name="getBooks" result="_nextFunction.apply(this, [event])" fault="Alert.show(event.toString())">
    </mx:operation>
    <mx:operation name="addBook" result="_nextFunction.apply(this, [event])" fault="Alert.show(event.toString())">
    </mx:operation>
    <mx:operation name="getBook" result="_nextFunction.apply(this, [event])" fault="Alert.show(event.toString())">
    </mx:operation>
  </mx:WebService>

  <mx:Model id="MyBook">
    <Book>
      <title/>
      <author/>
      <isbn/>
    </Book>
  </mx:Model>

  <mx:Script>
    <![CDATA[
      import mx.collections.ArrayCollection;
      import mx.controls.Alert;
      import mx.rpc.events.ResultEvent;
      
      private var _nextFunction: Function;

      public function testClick(): void {
        step1();
      }

      private function step1(): void {
        _nextFunction = step2;
        webService.getBooks();
      }

      private function step2(event: ResultEvent): void {
        if ((event.result as ArrayCollection).length != 0) {
          trace("assert: " + event);
        }

        _nextFunction = step3;
        MyBook.title = "Building Web Services with Java";
        MyBook.author = "Steve Graham, et al.";
        MyBook.isbn = "ISBN0-672-32641-8";
        webService.addBook(MyBook);
      }
      
      private function step3(event: ResultEvent): void {
        _nextFunction = step4;
        MyBook.title = "Designing Web Services with the J2EE 1.4 Platform";
        MyBook.author = "Inderjeet Singh, et al.";
        MyBook.isbn = "ISBN0-321-20521-9";
        webService.addBook(MyBook);
      }

      private function step4(event: ResultEvent): void {
        _nextFunction = step5;
        webService.getBook("ISBN0-672-32641-8");
      }

      private function step5(event: ResultEvent): void {
        _nextFunction = step5;
        MyBook.title = event.result.title;
        MyBook.author = event.result.author;
        MyBook.isbn = event.result.isbn;

        if ("Building Web Services with Java" != MyBook.title) {
          trace("assert: " + event);
        }
        if ("Steve Graham, et al." != MyBook.author) {
          trace("assert: " + event);
        }
        if ("ISBN0-672-32641-8" != MyBook.isbn) {
          trace("assert: " + event);
        }
        
        _nextFunction = step6;
        webService.getBook("ISBN0-321-20521-9");
      }

      private function step6(event: ResultEvent): void {
        MyBook.title = event.result.title;
        MyBook.author = event.result.author;
        MyBook.isbn = event.result.isbn;

        if ("Designing Web Services with the J2EE 1.4 Platform" != MyBook.title) {
          trace("assert: " + event);
        }
        if ("Inderjeet Singh, et al." != MyBook.author) {
          trace("assert: " + event);
        }
        if ("ISBN0-321-20521-9" != MyBook.isbn) {
          trace("assert: " + event);
        }
      }
    ]]>
  </mx:Script>
</mx:Application>