top of page

How to be a Web Service Consumer(wsc) as a SOAP client in Java?

Updated: May 7, 2020

Use Case: Business wants to use data in Salesforce to perform a business process outside Salesforce.

Solution: Use SOAP API to create, retrieve, update or delete Salesforce records.

Create a client SOAP API in Java which perform these functions.


Prerequisites:

Download the enterprise wsdl from Salesforce


In the IDE - used for building Java application - add the following .jar files into its workspace(Java Build Path | Add External JARs):

tools.jar or (C:\Program Files\Java\jdk1.6.0_26\lib\tools.jar to C:\Program Files (x86)\Java\jre1.8.0_211\lib\ext)

force-wsc-43.0.0.jar

js.jar

ST-4.0.7.jar

antlr4-4.1-complete.jar

com.sforce.ws.tools.wsdlc

Note: Save these files in a seperate folder within your Java project folder. Also save the wsdl(i.e enterprise.wsdl.xml) in this folder


The final command to generate Java stub files:


java -classpath force-wsc-43.0.0.jar;js.jar;ST-4.0.7.jar;antlr4-4.1-complete.jar com.sforce.ws.tools.wsdlc enterprise.wsdl.xml .\stub\enterprise_stub.jar

Note: the command will generate the stub jar file in a folder - stub.

[WSC][wsdlc.main:71]Generating Java files from schema ... [WSC][wsdlc.main:71]Generated 1085 java files. [WSC][wsdlc.main:71]Compiling to target 1.6... warning: [options] bootstrap class path not set in conjunction with -source 1.6 1 warning [WSC][wsdlc.main:71]Compiled 1089 java files. [WSC][wsdlc.main:71]Generating jar file ... .\stub\enterprise_stub.jar [WSC][wsdlc.main:71]Generated jar file .\stub\enterprise_stub.jar


Add the stub jar file in the workspace of the IDE of the Java project.


Now you are ready to build the WSC in Java.


Refer to code in the following link - https://github.com/JohnsonTitus/javaSOAP_API_call

Recent Posts

See All
Apex as a Web Service

Use case: By using one interface, call center representatives can view and update case records in Salesforce and access internal...

 
 
 

Comments


Post: Blog2_Post

©2020 by SalesforceDemystified. Proudly created with Wix.com

bottom of page