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
EPSWDEVEPSWDEV 

Calling a Apex class method exposed as a webservice.

Hi,

I have a APEX Class whose one method I have exposed as a webservice and I am trying to call it using Java. What are the general steps I need to do in order to call this service successfully. I have seen various examples on the wiki where a java client would can access and perfrom operations on various salesforce objects using the Web Service API, However none of them show how to call a apex class exposed as a webserivce and pass data to it and recieve a response. (my Data operations are done in the method exposed as the webservice). Looking for the phptoolkit equivalent  for java.

Thanks,
aalbertaalbert
When you define an Apex method as "webService", Apex provides you a WSDL you can then import into your development environment. For Java, something like WSDL2Java. And just like any other salesforce.com web service, you will need login to generate a sessionId, set the SessionId in the SOAP Header, and then you can call your custom Apex web service in a similar fashion as the standard web services, such as insert or update.

Also, the custom WSDL will include any inner classes or members that were labeled "webService".

To generate the WSDL from the salesforce.com User Interface, login, go to Setup->App Setup->Develop->Apex Classes. Find the specific class where the web service is defined and click on the WSDL hyperlink. This will download the WSDL which can then be imported into the external application(s) that will be invoking the web service.

EPSWDEVEPSWDEV
I have installed axis2 and ant and was able to generate and build the source  by feeding the WSDL file to WSDL to java. The result of the build was a <My web svc name>_client.jar.

My question is what does WSDL2Java do? when I ran it, it generated a lot of classes and am not sure if anything needs to be modified in it before I build it. Does it generate like a 'proxy' to the <my web svc> that once compiled I can use elsewhere in my java code refer and make calls to the websvc? or am I wrong.

Thank you