You need to sign in to do that
Don't have an account?
typemismatch
Apex and Flex 2 Web Services
I know this is supposed to be possible but I can't find any docs - I saw it at the last dev conf.
I have a webService exposed via Apex and I need to access that data from Flex Builder 2 but I can't seem to get it working.
If anyone has done this or knows where the docs are please get back to me.
thanks
-c
http://www.salesforce.com/us/developer/docs/apexcode/salesforce_apex_language_reference.pdf
WebService Methods
Apex Code class methods can also be exposed as custom ApexWeb Services API calls. To do so, use the
webService keyword.
For example:
class MyWebService {
webService static Id makeContact(String lastName, Account a) {
Contact c = new Contact(lastName = 'Weissman', AccountId = a.Id);
insert c;
return c.id;
}
}
then, from flex there are objects that come with Flex Builder, bring up the help contents , search for webservice
Hide MXML Syntax
The <mx:WebService> tag accepts the following tag attributes:
there is still lots of work to put these two together, but this is the starting doc.
Ron,
I'm just starting to dive into this and have noticed that when creating a WebService instance in MXML it requires an address to the WSDL... which is only accesible after logging in. Does this mean we would have to login first and then create the instance later with ActionScript? (obviously I am referring to the scenario of logging in 'apollo style' from the desktop.)
you can find examples in the src code for the flex toolkit, look at
connection.as and transport.as, xmlwriter.as
we use mx.rpc.http.HTTPService and not WebService().
just like the Ajax toolkit we roll our own XML from objects ( look for toXml() and XmlWriter() )
in fact i strongly suggest you use Transport().send(), which takes an XmlWriter() object
This class has a (special) flag to get back Faults from the Soap API in a manner compat with Flash, which you will need to see any error messages at all.
the pseudo code is basicaly
_invoke()
new xmlWriter()
add namespaces, header stuff
loop over methods, objects buildind XML
add end tags
call new Transport(). send()
see line ~850 of Connection.as
I've just banged my head up against this, and found this thread from a few months back. I need to use apex transaction support when updating the database from a Flex app, and this seems the best way to do it. Has anyone successfully called an Apex class web service from Flex?
From this thread, it looks as if the problem with using the Flex WebService by itself is you don't get a sessionId in the SOAP header. The Connection object from the toolkit has that cached after Login, so extending Connection to also support the class web service seems like a good way to support this. I tried that and of course it didn't work. Two questions: 1) I assume I need to pass another url to 'invoke' other than what I got back from login, should that be the url of the wsdl the class generates? 2) Do I need to include any of the other invoke parameters that aren't being used by the api calls (like nsMap, sfNs, etc.) ?
Any help would be greatly appreciated.
Jay