8 Replies Latest reply on Apr 12, 2009 7:06 PM by Wilson Edgar

    ResultEvent is always null

      Hi all

      I aplogise if this has been asked before but I've actually looked for an answer and couldn't find anytthing.

       

      <mx:Script>

      <![CDATA[

      import mx.messaging.channels.StreamingAMFChannel;

      import flash.net.sendToURL;

      import mx.controls.Alert;

      import mx.rpc.soap.SOAPFault;

      import mx.rpc.events.ResultEvent;

      import mx.rpc.events.FaultEvent;

       

      private function HandleFault(event:FaultEvent) : void

      {

      Alert.show(event.fault.faultDetail, event.fault.faultString);

      }

       

      private function HandleResult(event:ResultEvent) : void

      {

       

      if(event != null){

      if(event.result != null){

      LblDisplayJava.text = event.result.toString();

      }

      else{

      Alert.show("Event result is null", "Webservice result");

      }

      }

      else{

      Alert.show("Event result is null", "Webservice result");

      }

      }

       

      private function InvokeWebService() : void

      {

      JavaTestWebService.sayHelloWorldFrom.send(TxtName.text);

      }

       

      private function InvokeHelloWorld() : void

      {

      DotNetService.HelloWorld.send(TxtName.text);

      }

      ]]>

      </mx:Script>

      <mx:WebService id="JavaTestWebService" wsdl="http://localhost:8080/services/HelloWorld?wsdl"

      showBusyCursor="true" useProxy="false"

      fault="HandleFault(event)" result="HandleResult(event)">

      <mx:operation name="sayHelloWorldFrom">

      <mx:request>

      <from>{TxtName.text}</from>

      </mx:request>

      </mx:operation>

      </mx:WebService>

      <mx:Panel x="0" layout="vertical">

      <mx:HBox>

      <mx:Label id="LblName" text="Type in your name:" />

      <mx:TextInput id="TxtName" width="300" />

      <mx:Button id="BtnRequestJava" click="InvokeWebService()" label="Salute Java"/>

      </mx:HBox>

      <mx:HBox>

      <mx:Label id="LblDisplayJava" text="This should be the result"/>

      </mx:HBox>

      </mx:Panel>

       

      This is invoking a simple java code

       

        public String sayHelloWorldFrom(String from) {

          //String result = "Hello, world " + from;

          System.out.println("Service invoked");

          return "Hello world Wilson Edgar";

        }

      Everytime I run this I get event.result as null.

      The webservice is being invoked and everything seems to okay, except for the result. Now I've run the same code calling a .NET webservice and it works just fine. Unfortunately I have to develop my project in Java so any help would be much appreciated.

      Thanks in advance for you time

      Wilson Edgar