Using Salesforce SOAP API from Java Code

Recently i had to develop a portlet that talks to and retrieves some data. I decided to use the SalesForce SOAP API for that, i followed these steps
  1. First step is to get your security token, follow steps as described in Generating Security Token for post for that
  2. Second step is to login into your account and download the Enterprise .wsdl, Follow steps 1-3 from Accessing SalesForce data using SOAP Service - SoapUi post for that
  3. You should use the web services connector (WSC) which has helper code that simplify working with SOAP service.
  4. Once you have WSC project downloaded on your machine and complied into jar copy it in a directory and then also copy your enterprise.wsdl in the same directory, then execute
    java -classpath target/force-wsc-29.0.0-jar-with-dependencies.jar enterprise.wsdl enterprise.jar
    It will generate enterprise.jar file for you
  5. Now create a Java Project and add both enterprise.jar and force-wsc-29.0.0-jar-with-dependencies.jar in your classpath
  6. Last step is to create class like this Replace userId, password and securitytoken in this file with the values you have
  7. When you run the class it will display list of contacts in your account

1 comment:

Anonymous said...

Hi Sunil,
The soap enterprise connector package is missing when I follow these steps. Can you let me know if it worked for you the first time?