• FlexJosh
  • 0 Points
  • Member since 2009

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
  • 2

Hi all,


I am trying to create a s-control or Visualforce page that has a Flex app embedded in it.  I have no problem embedding the Flex app, the problem comes when I need to query an outside RESTful web service.  I understand this is done in javascript by going through the RESTful proxy, which Salesforce facilitates with a method named sforce.connection.remoteFunction().


I noticed that in the force-flex toolkit there is an (undocumented!) object called Connection2 which also has this method.  However, every time I try calling this method (and thus the proxy) the proxy returns an HTTP 406 error.


Has anyone successfully done a RESTful call through the proxy using Flex?  How could I go about doing that?



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.