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
tony534tony534 

java client access salesforce custom web service with WSC

Hi, 

 

I read the salesforce api document and blog()and tried to call the web service with WSC, but I don't know how can I call the custom web service via WSC.

 

Any suggestion will be appreciated.

pkurapkura

You need to do the following to achieve this :

 

1) Get the custom webservice wsdl (if the webservice is defined in Apex, you've Generate WSDL option next to your apex class (assuming you've right privileges)).

2) Generate java stubs for your wsdl using Apache tool wsdl2java part of Apache axis library (I used 1.4 ver. you can try a diff. one).

3) Create a jar of the generated classes (this is just a convenience rather than having all the generated classes in your class path).

4) Generate axis stubs of the partner wsdl using wsdl2java (If you're using enterprise wsdl, replace partner with enterprise).

5) Get the session Id using wsc partner connection.

6) Set the session Id in your custom webservice binding generated using apache axis.

     For Ex:

     customWebServiceBinding.setHeader(new customWebServiceLocator().getServiceName().getNamespaceURI(), "SessionHeader",
                new SessionHeader(partnerConnection.getConfig().getSessionId()));

     customWebServiceBinding.createAccount(accountParameters);

Make sure  you've wsc-xx.jar, partner-xx.jar, partner-axis.jar (generated using axis and partner wsdl), customwebservice.jar (generated using wsdl2java and custom webservice wsdl). XX- refers to wsc version you're using.

 

 

Avi646Avi646

Now SessionHeader in wsc is changed to SessionHeader_element but while using the same in the code gives the following Error.

 

No serializer found for class com.sforce.soap.partner.SessionHeader_element in registry org.apache.axis.encoding.TypeMappingDelegate@96cf11

 

Doug JDoug J

I appreciate your taking the time to put this information out there.  I've been working several hours however, downloading Apache and Axis and generating code as described and now I am to the point of coding - but I need a little more.  In my generated code I do not see any classes that have as part of their name, "WebServiceBinding" or "...WebServiceLocator".  

 

Can you give a little more advice on how to find the classes that need code added to them?

pkurapkura

Which version of Axis did you use to generate the stubs ? Can you list the class names that are generated using axis ?