Flex Remoting - Remote Application Calling Web Service

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

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.
ToddBPetersonAuthor Commented:
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...

ToddBPetersonAuthor Commented:
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!
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ToddBPetersonAuthor Commented:
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,
ToddBPetersonAuthor Commented:
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!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Flex

From novice to tech pro — start learning today.