Generate Java client code for Salesforce SOAP API

When using Salesforce's SOAP API, generate client-side code from the wsdl file. https://developer.salesforce.com/page/Introduction_to_the_Force.com_Web_Services_Connector

When one program communicates with multiple SalesForce instances using SOAP API, client-side code is generated for each instance. At that time, it is an introduction of the method to prevent the package name from being duplicated.

Advance preparation

Basically, it is good to refer to Force.com Web Service Connector (WSC). The method has been improved little by little, so check here for the latest method.

How to generate

  1. Create force-wsc-x.y.z-uber.jar
  2. Download wsdl
  3. Code generation

1. Create force-wsc-x.y.z-uber.jar

First, build the jar to generate the code from wsdl from the source of wsc.

git clone https://github.com/forcedotcom/wsc.git
mvn clean package -Dgpg.skip -DskipTests

If gpg authentication or testing fails, pass the parameters to skip as above. If the build is successful, a jar called force-wsc-x.y.z-uber.jar will be generated under target.

2. Download wsdl

Log in to your SalesForce instance and go to the Settings> Development> API screen. There is a download link for the wsdl. There are various types, but for normal data exchange, Enterprise WSDL will not be a problem.

スクリーンショット 2017-03-20 11.43.38.png

3. Code generation

main in com.sforce.ws.tools.wsdlc.java I am generating code with a method. See here for what's in the system properties for tweaking.

To prefix the package:

java -Dpackage-prefix=XXX -jar target/force-wsc-x.y.z-uber.jar enterprise.wsdl enterprise-XXX.jar

The package structure is com.sforce.soap.enterprise.XXX. After that, if you refer to each generated jar as a separate library, you can handle client-side code of multiple instances.

Reference site

Recommended Posts

Generate Java client code for Salesforce SOAP API
Tips for using Salesforce SOAP and Bulk API in Java
Java HTTP Client API timeout setting
Generate CloudStack API URL in Java
Generate Dart client code with Rails + apipie
[MarkLogic] CRUD + α by "Java Client API"
Hit the Salesforce REST API from Java
[Salesforce] Registering and updating static resources with Tooling API (Java sample SOAP API)
ChatWork4j for using the ChatWork API in Java
Technology for reading Java source code in Eclipse
I made an API client for Nature Remo
Docker Container Operations with Docker-Client API for Java
Script Java code
Java code TIPS
For JAVA learning (2018-03-16-01)
I wrote a test code (Junit & mockit) for the code that calls the AWS API (Java)
Java sample code 02
Java sample code 03
Java Stream API
2017 IDE for Java
Java mqtt client
Java sample code 01
Java character code
Java for statement
[For beginners] How to operate Stream API after Java 8
Generate dummy data for various tests with Faker (java)
Sample code for log output by Java + SLF4J + Logback
Java: Timed token management class for Web API authentication
Links for each version (Japanese version) of Java SE API
[memo] Generate RSA key pair for SSH in Java