Monday, October 13, 2014

Invoke a SOAP API written in Salesforce using Axis

I had to consume an API written by someone else in Salesforce. I got the WSDL and the EndPoint.

Essentially what I had to do is to replace existing code I wrote a year ago to perform User Provisioning in Salesforce and rely on this API to perform that logic.

Now the interesting part is how to write my client, the obvious answer was to use WSDL2Java (Axis), because I don't want to write much code. And this is my final code: This is a simple Cooking recipe with the exception of these lines: Things to keep in mind (otherwise you'll get "INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session"):
  1. Open a session in Salesforce (that's how get permission to invoke the API)
  2. Populate SessionHeader object (with Salesforce sessionId)
  3. Set the Header to your Port before making your call