Generating Java Stub Files (WSDL-Based APIs)
To use WSDL-based Salesforce APIs with Java, you need to generate .jar stub files that you can use in your Java projects.
You’ll need the WSC .jar file to generate stub files. You’ll also need the appropriate WSDL files for the API you plan to use.
-
Open a command prompt window and navigate to the location where your WSDL and WSC .jar files are.
-
Generate the Java stub for the WSDL by using the following command in a command prompt window: java –classpath path to WSC jar/WSC jar filename com.sforce.ws.tools.wsdlc path to WSDL/WSDL filename path to output stub jar and filename. You might need to also include additional .jar files that WSC needs, such as Rhino or StringTemplate, in the classpath list, separated by semi-colons (on Windows) or colons (on Mac/Linux). See Install the Web Services Connector (WSDL-Based APIs) for more information on Rhino and StringTemplate.
An example Windows command for generating the stub .jar file “enterprise_stub.jar” using the API version 29.0 WSC and the Enterprise WSDL might look something like this:
1java -classpath \testWorkspace\wsc\force-wsc-29.0.0.jar;
2\testWorkspace\rhino1_7R4\js.jar;
3\testWorkspace\stringTemplate\ST-4.0.7.jar;
4\jdk\jdk1.7.0_17\lib\tools.jar
5 com.sforce.ws.tools.wsdlc
6 \testWorkspace\wsdl\enterprise.wsdl
7 \testWorkspace\stub\enterprise_stub.jar
Note that this example includes the Rhino and StringTemplate dependent .jar files in the classpath.