Verify the WSDL Environment (WSDL-Based APIs)
You can verify your developer environment with a simple Java test application in Eclipse.
You should have the JDK, Eclipse, and WSC installed, and have generated the Java stub .jar files for the WSDL files that you need to use. You’ll need the stub .jar file for either the Enterprise or Partner WSDL to follow the verification steps.
-
Run Eclipse. Click File | New | Java Project and name the project SF-WSC-Test.
-
Add the WSC and stub .jar files to your project. Click Project | Properties | Java Build Path | Libraries, click Add External JARs, select the WSC, and stub .jar files, and click OK.
-
Add a new folder to the src folder by right-clicking src, then select New | Folder and use wsc as the folder name.
-
Create a new class by right-clicking wsc and selecting New | Class. Name the class Main.
-
Replace the code Eclipse generates for Main.java as described in the following section.
Use the following simple login example code for your Main.java class. Replace YOUR DEVORG USERNAME with your developer organization username, and replace YOUR DEVORG PASSWORD AND SECURITY TOKEN with your developer organization password appended with your security token. If you did not set a security token in your organization, just provide your password. A GitHub Gist of this code is available here: https://gist.github.com/anonymous/78864d2c4ccfe4e983ef.
1package wsc;
2
3import com.sforce.soap.enterprise.Connector;
4import com.sforce.soap.enterprise.EnterpriseConnection;
5import com.sforce.ws.ConnectionException;
6import com.sforce.ws.ConnectorConfig;
7
8public class Main {
9 static final String USERNAME = "YOUR DEVORG USERNAME";
10 static final String PASSWORD = "YOUR DEVORG PASSWORD AND SECURITY TOKEN";
11 static EnterpriseConnection connection;
12
13 public static void main(String[] args) {
14
15 ConnectorConfig config = new ConnectorConfig();
16 config.setUsername(USERNAME);
17 config.setPassword(PASSWORD);
18
19 try {
20
21 connection = Connector.newConnection(config);
22
23 // display some current settings
24 System.out.println("Auth EndPoint: "+config.getAuthEndpoint());
25 System.out.println("Service EndPoint: "+config.getServiceEndpoint());
26 System.out.println("Username: "+config.getUsername());
27 System.out.println("SessionId: "+config.getSessionId());
28
29 } catch (ConnectionException e1) {
30 e1.printStackTrace();
31 }
32 }
33}
The following example output shows a typical successful run of this code.
1Auth EndPoint: https://login.salesforce.com/services/Soap/c/27.0
2Service EndPoint: https://yourInstance.salesforce.com/services/Soap/c/27.0/00DU0000000L5f0
3Username: testuser@testorg.com
4SessionId: 00DU0000000Q5f0!ARoAQDjpkH.NReBp_vBLZ124aDbgYM_v7so9ciUu
If the verification Java project runs and displays output that matches your organization, your developer environment is set up and you can start developing Java applications that integrate with Salesforce.