function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
EJWEJW 

Flex API & Apex Code Web Services Issues

Running into a few issues with the Apex Flex library and Apex Code web services.

1) If you attempt to call an Apex web service via Connection.execute() that has no arguments you'll get one of several error messages back depending on how you attempt to call the web service.  Is there a correct method for doing this with the latest Flex library?  It currently won't allow you to pass a null, an empty array or an array containing a null as the argument list for the WS.

2) If you attempt to call an Apex web service that returns no results, you'll get a null value exception when the WS returns.

3) Exceptions thrown by Apex Code don't appear to be coming back to Flex in any manner.  If Apex Code throws an exception  the callback is never called and no Flex exception is thrown, so the application basically sits in limbo.

Has any one else experienced this?  Are these known issues?
Ron HessRon Hess
this functionality was added recently and there are currently no unit tests in place for calling Apex WS, we will work on adding some unit tests, including the ones you mention and update the library as required.

thanks for reporting this, we will try to release a new library soon after the Winter08 goes live on all servers.
Ron HessRon Hess
ok, i was able to find and fix the issue you report with void return value, i've checked in a fix and also added test cases for this.

you can see the unit tests in the directory test/FlexUni/Flex2/ExecuteTestCase.as

1) the call should work with a null array when no paramaters are expected by the webservice:
apex.execute("webServiceTest","testService",[],ar);   

2) fixed by catching and returning null to your responder

3) i've created a test webservice that throws a null pointer exception, this is returned to the fault handler in the async responder, you can see this in the unit test. 

The unit tests are checked in, the next build of the library will have these fixes, probably next week.  If you need it sooner, you can build the srcs. 
Br1Br1
Hi Ron, i have done the connection test without problems, but when i try to run a class at my org, flex throws a null exception, i dont know if i have to do something more at the framework to expose my apex class.

The code of my apex class are :

global class FlexWebService {

webservice static Integer getDouble (Integer x) {
Integer test = x * 2;
return test;
}

}

The AS code are:

var ar : AsyncResponder = new AsyncResponder(
function(result){
trace('Result Received'+result);
},
function(fault){
trace('Fault Received'+fault);
}
);

connection.execute("FlexWebService","getDouble",[1],ar);

The error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.salesforce::Connection/execute()[/Users/rhess/Documents/workspace/mavericks/sdk/src/com/salesforce/Connection.as:518]

Thanks.
Bruno.

Message Edited by Br1 on 10-08-2008 11:30 AM

Message Edited by Br1 on 10-08-2008 11:31 AM
EJWEJW
The problem might be with the third parameter of your connection.execute() call (the [1]). connection.execute expects an array of Parameter objects. Try changing your third parameter to: [new Parameter( "x", 1, false )]
Br1Br1
Thanks for the reply EJW, it works ! , was the parameter.

Message Edited by Br1 on 10-08-2008 12:10 PM
PXForcePXForce

Hi Ron,

 

Could you please look at the following and guide me in the right direction. I am badly stuck with this issue:

 

http://community.salesforce.com/t5/Apex-Code-Development/cannot-access-data-from-Apex-web-services/m-p/204523

 

any help would be greatly appreciated.

 

Thanks