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

apex webservice model as parameter from Flex



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.


Did you ever get anywhere with this?  I believe I am trying to do something similar with no luck.
Unfortunately, I didn't found a solution to this problem.



I am trying something similar.  Were you able to get a solution for this. Thanks.



Still no solution found :-(

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.