Flex Remoting - Remote Application Calling Web Service

Posted on 2009-05-28
Medium Priority
Last Modified: 2012-05-07
Hi All,

I've been recently playing around with Flex Remoting, using BlazeDS.  I'm able to build upon the examples, and have a simple Flex application return the results of a Java object call (simply a helloworld type of example).

What I would like to have my Java object do is call a web Service...  Everything is running on my local PC, and my local PC has access to the web service.  However, everytime I swap out the helloworld code, with the call to the web service, I don't get a return value.  I'm able to execute the Java code, stand-alone, and make the web service call, but when I plug it into my implementation for usage from Flex, it doesn't return anything...  I'm attaching the sample code below...  NOTE: The code below works...  when I uncomment the WS code though, it doesn't...

Is there something obvious that I'm missing?  More importantly, are there debugging techniques that can help me isolate the problem?

Any help would be greatly appreciated!
Remote Java Code:
package flex.samples.paths;
//import com.dst.cdsl.services.client.CDSLPort;
//import com.dst.cdsl.services.client.CDSL_Impl;
public class CDSLIntermediary
    	public String getPaths() {
//    	    CDSLPort client = null;
//    	    String resXML = null;
//    	    try {
//    		    client = (new CDSL_Impl( "http://internalapp.com/cdsl/CDSL?WSDL" )).getCDSLPort();
//    		    resXML = client.getPathsByCusipDocType("test");
//    	    }
//    	    catch (Exception e) {
//    	    	System.out.println("Exception in WS call: " + e.getMessage());
//    	    }
//    		System.out.println("resXML = " + resXML);
    		String resXML = "Hello, from inside the Remote Java Object";
    		return resXML;
Flex Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" backgroundColor="#FFFFFF">
	<mx:RemoteObject id="srv" destination="paths" />
	<mx:TextArea text="{srv.getPaths.lastResult}"/>
	<mx:DataGrid dataProvider="{srv.getPaths.lastResult}" width="100%" height="100%"/>
	<mx:Button label="Get Data" click="srv.getPaths()"/>	
remoting-config.xml entry:
    <destination id="paths">

Open in new window

Question by:ToddBPeterson
  • 4
  • 2
LVL 19

Expert Comment

ID: 24496049
On the remote object you need to add a result handler to the remoteobject.  When the ro method executes it will come back to Flex and you need to handle it in some way.

<mx:RemoteObject id="srv" destination="paths" >

<mx:method name="getGridData" result="getGridDataResult(event)" />


Then in the getGridDataResult method put a break point and inspect the result set coming back from java.

Then you can see if the data is in the correct format.

Author Comment

ID: 24496226
Ahhh...  I should have removed the DataGrid, as I had commented that out, directly from the BlazeDS example (I'm not using that component at all...  the commented code I was referring to in my original post, is the remote Java object code)...  I'm assuming the same applies to the TextArea that I'm using though...

I'll give it a try and post my results...


Author Comment

ID: 24497848
I found out what my problem was...  I didn't copy the two supporting .jar files to the WEB-INF\lib directory.  Once I moved them over, the remoting call worked and the results were displayed in the Flex client.

Another question, if you please?  What role does BlazeDS play in this architecture?  I have:
1. A standard Java object (POJO with public method deployed to WEB-INF\classes)
2. A stand Flex application with an mx:RemoteObject call (deployed to webapp directory)
3. A remoting-config.xml file resolving the Flex mapping to the Java object (deployed to WEB-INF\flex directory)

I don't understand how BlazeDS participates in the architecture.  Does it intercept calls on the web server side, peform marshalling, etc.  It's completely transparent to how the application is built and deployed...  It was great for a source of sample applications, with it's "test drive" application, but I'm not sure if and to what extent it's needed???

Thanks in advance for the feedback!
Live webcast with Pinal Dave

Pinal Dave will teach you tricks to help identify the real root cause of database problems rather than red herrings. Attendees will learn scripts that they can use in their environment to immediately figure out their performance Blame Shifters and fix them quickly.

LVL 19

Accepted Solution

Jones911 earned 2000 total points
ID: 24497880
Its like the bit between your java code and flex.  It does the messaging and the conversions between flex ( amf ) and java.  Like you mentioned it intercepts the calls.  It also will allow for full push data from the server.  Beign free and open source are also great parts of Blaze.

Author Comment

ID: 24502703
Makes sense!  Thanks for the info!

My ultimate goal is to deploy an application to our existing infrastructure, which would involve a web/app server cluster, such as Sun Java web servers and BEA Weblogic app servers.  The app servers, in-turn, will have access to the internal web services I have been trying to remote to all along.

Looking at the Tomcat deployment, it seems that all I would have to do, to deploy to a different web/app server framework, would be to build a .war file, which includes the following:
1. WEB-INF\classes directory - containing the remote object classes with the core business logic
2. WEB-INF\flex directory - containing the xxx-config.xml files, specifically the remoting-config.xml file
3. WEB-INF\lib directory - containing all of the BlazeDS .jar files and any supporting .jar files I need

Does that about sum it up?  Is it that simple?  Is there any other configuration/setup required to get BlazeDS running on a different target platform?

Thanks so much, again, for all of the assistance!  I'm starting to feel pretty good about the potential use of Flex, within our organization, as a part of our over-all enterprise architecture!

Best Regards,

Author Closing Comment

ID: 31586367
Thanks for the input!  I have been successfully able to get a blazeds sample working with only the minimal components.  Although I haven't had any luck with a BEA Weblogic deployment, I am able to deploy to a JBoss envionment with no problem.

I now understand the BlazeDS framework, and how to leverage it in a Flex/Java integration.

Thanks again!

Featured Post

Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
Sometimes when I'm using my iPad, one of my apps will start acting weird or it just stops working. After reading articles and finding solutions on my own, I decided to share solutions I have found helpful.
In this video I will demonstrate how to set up Nine, which I now consider the best alternative email app to Touchdown.
When you have multiple client accounts to manage, it often feels like there aren’t enough hours in the day. With too many applications to juggle, you can’t focus on your clients, much less your growing to-do list. But that doesn’t have to be the cas…

587 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question