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
SimbaSimba 

Urgent !! Sample Code to make a call to Apex Web Service from Java

I have created an APEX Web Service and would like to call it from outside. Can you please give me the steps to access APEX Web Service from outside.

I have the document calling SF APIs from outside, this does not talk about making calls to APEX Web Service.

1. Do I need to get an handle to describeGlobal ?
2. Do I need to have some kind of SF jar files to get APIs for SF objects (like DescribeGlobalResult;, SforceServiceLocator() );

Thanks

Regards



wintamutewintamute
Hi,
if you have webservices exposed via apex code you can generate wsdl files for these similar to the other wsdl files.
These contain everything necessary to create the java files to access your webservice methods.
You can generate your apex wsdl files via the Apex detail page: Setup->Develop->Apex Classes , click on the name of the apex class, then click on Generate WSDL.
After that it's basically the same as with standard salesforce functionality and can be used like described in the documentation.

regards,
Andreas


Message Edited by wintamute on 04-01-2008 04:33 PM
dallas_sfdallas_sf
Hi,
So would you need both the Enterprise WSDL as well as the WSDL for the Apex class?  Is there a small sample that walks through this?  Also, in the Apex Language Reference guide it only lists Triggers, AnonymousExecute and AJAX as ways to invoke Apex code

Thanks
SimbaSimba
Yes you would need both Enterprise WSDL as well as the WSDL of your APEX WebService. Using the Enterprise WSDL you would use the SF webservice the get the Soap Binder and then login to the SF application, buy providing the SF user Id and pswd. The SF would then return the Session ID into this Soap Session Header, which will be valid for 2 hours (Not sure if this can be extended or not).
Once you have the session Id, you can save this either at the application level and then keep using this again and again till it's expired. Using this session Id you would make a call to your Apex WebService, like you would make a call to any other WebService

I don't have the sample code handy with me right now, but I had found one with .Net example somewhere on the Wiki. May be you can try searching there.