Expand my Community achievements bar.

ResultEvent is always null

Avatar

Former Community Member

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

8 Replies

Avatar

Level 3

Hi Edgar, just for curiosity have you try invoking the web service from a web page?

Avatar

Former Community Member

Yeah, I have and it works fine....

I seriously don't understand why event.result is null

And where do I find docs about this, you the ResultEvent object

or is it all trial and error?

Thanks

Wils

Avatar

Level 3

Hi Wilson you can take a look at the livedocs http://livedocs.adobe.com/flex/3/html/help.html?content=data_access_6.html or make a search in the Flex Bug Base, what SDK do you have installed?

Avatar

Former Community Member

Hi there Michael first and foremost, thanks for your interest I'll be browsing the docs now

the flex sdk I have installed is:

Version 3.3.0 build 4852

Again thanks.

Wils

Avatar

Level 3

You're welcome Wilson, I'm curious about your problem. Once you find a solution which I hope will be very soon I strongly recommend you to post it here and mark it as answer so when someone else has the same issue it'll find a solution faster.

Have a good day.

Avatar

Level 3

Hi Wilson, something I forgot to recommend you was to use TraceTarget, maybe you've already tried this but in case you didn't, right after your mx:application tag add

<mx:TraceTarget />

And then run the app in debug mode and make the service call then take a look at the console to see what data is being sent and recieved from your app to your webservice.

Avatar

Former Community Member

Hi there Michael,

I'm now thinking that the problem is in how java generates the wsdl, consequentely the response.

This is the xml response I'm receiving from the .net services:

<?xml version="1.0" encoding="utf-8"?>

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<soap:Body>

<HelloWorldResponse xmlns="http://tempuri.org/">

<HelloWorldResult>Hello Hello there, how are you today?</HelloWorldResult>

</HelloWorldResponse>

</soap:Body>

</soap:Envelope>

and this is what I'm getting from java

<?xml version="1.0" encoding="UTF-8"?>

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<soapenv:Body>

<fromReturn xmlns="http://example">Hello world Wilson Edgar</fromReturn>

</soapenv:Body>

</soapenv:Envelope>

As you can see there are some differences, the reason why I say is because initially to test webservice (the java one) I created a client in java and it worked fine, but after reading your email, again, I decided to call the java webservice from a .net enviroment.... guess what, the return string is null.

So this is not a problem in flex but it's rather on the java side.

Althouhg now, I think, I understand better what's going on, I still don't have a solution :-(

Thanks

Wils

Avatar

Former Community Member

p.s

I'm using Axis to expose the Java webservice