You need to sign in to do that
Don't have an account?
apex webservice model as parameter from Flex
Hello,
Whole day I've tried to Connect from a Flex app to a salesforce webservice. I started with a simple HelloWorld with parameters of default types (String, Integer, ...)
Now I want to send a model (MyContact) to the apex webservice and then return MyContact.firstName and MyContact.lastName.
Here my apex webservice:
global class HelloWorldWebservice{
//MyContact model
global class MyContact
{
webservice String lastName;
webservice String firstName;
}
WebService static String SayHelloName(String name){
return 'Hello '+name+ '!';
}
WebService static String SayHelloContact(MyContact mycontact){
return 'Hello '+contact.firstName+ ' ' +contact.lastName+'!';
}
}
To call the SayHelloName method in Flex I used the following:
var object:Parameter = new Parameter("name", helloInput.text); var params:Array = [object];
force.execute("HelloWorldWebservice","SayHelloName",params,new AsyncResponder(SayHelloNameSuccess, faultResponder));
Above works perfect, but my next challenge is to send a model MyContact to the webservice, this is what I have at the moment:
var firstName:Parameter = new Parameter("firstName","Kevin"); var lastName:Parameter = new Parameter("lastName","Neuteleers");
var myContactFields:Array = [firstName, lastName];
var myContact:Parameter = new Parameter("mycontact", myContactFields);
var params:Array = [myContact];
force.execute("HelloWorldWebservice","SayHelloContact",params,new AsyncResponder(SayHelloNameSuccess, faultResponder));
Hopefully there's someone who knows an answer and wants to help me.
Hi,
I am trying something similar. Were you able to get a solution for this. Thanks.
Sanch.
Unfortunately from what I've found, objects don't pass too nicely between Flex and Apex classes. I had to work around it by passing only String values.
I bet something can probably be done with XML to normalize the objects, but in my case the objects were not complicated enough to need something like that.