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

Tuesday, September 16, 2014

Querying a DATE field and a TIMESTAMP

When I was running a few reports, I faced a very interesting scenario.
(Because I'm lazy I wrote a Stored Proc with all my queries and used a scheduled Job to run it)

Anyway, the idea here is that I had to run my report for a certain window of time.
So I declared my start date and end date variables as DATE and wrote all my queries using: And when I ran for the first time my queries in the body of the Stored Proc I got a bunch of errors. Why???

After thinking seriously, that maybe I've lost my edge I just realized that in a few tables the created_on column was declared as DATE and in others as TIMESTAMP. Not the end of the world, I just decided to change the data type of my variables to TIMESTAMP and end of the story :)