Anybody working with the salesforce API

I imported the sforce API WSDL file into developer and I now have my sforce functions available as web service connectors. I’m using the login connector and this returns me the loginResponse with the correct serverUrl & SessionID. Sforce doc tells to keep those 2 variables and pass them to other functions during the session -by changing the SOAP header-. My question is, How do I do this ? No functions have serverUrl & sessionID in input…


Describing soap header variables in WSDL is not well understood and generally not done in a standard way. I think it was for this reason, the IS web services connector wizard ignores soap header elements even if the WSDL contains them.

Per the soap spec, the WSDL should define a message part for each element in the soap header. You may have to inspect the WSDL manually or with your favorite WSDL editor (XML Spy Enterprise, CapeClear WSDL Editor, etc.) in order to determine the structure of the soap message header that SForce requires. It should be described as an element in the types section of the WSDL.

Create a documentType that conforms to that type, populate it and then add it to your subsequent soap requests using the pub.soap.utils:addHeader built-in service.



I have question on the samelines. Salesforces says that we have to use their session id everytime we send a message to their server after successful login. My question is If I have to use the session Id at different intervals what is the best practise/way to store session id ? I would like my message to go thru TN.

Can you describe the process in more detail? Are there are multiple, asynchronous interactions? I would assume that you wouldn’t stay logged in between those interactions.

Let me give you an example. Lets say I have a account with salesforce, when I use login service, I get the session id. Now for each account the session is valid for 1 hour by default I believe. Lets say I do a transaction immdiately after I login and there is time gap between my first transaction and second transaction in which case I should have a place holder/store the session id to make sure I use that before I make a another call.
There could be multiple async interactions.
The way salesforce work If I am right is all they need is a session id which is valid for a period of time. So If I hv a session id stored I can make multiple calls and once the session is expiring I will re-login and get a new session.

I would suggest not holding on to the session. Instead:

  1. Log in, getting the session ID.
  2. Do your transaction.
  3. Log out.

One might wince at the supposed “wasted bandwidth” of logging in and out for each transaction but it has the advantage of keeping your integration stateless and simple. Trying to keep the session ID for multiple, time-independent transactions will be troublesome.

Other options to consider:

  • Session pooling.
  • Batching.

In case of salesforce holding session is not exactly what they mean :-
What I understand from them is its a key which they use to authenticate/validate a request from client perspective. But that session is still active with their server. And they do not hv any other mechanism of authenticating/authorizing/validating a request.

Batching is approach being followed. The idea behind to have session ID stored is the volume of transaction that will happen backnforth from salesforce. In this case Logging in everytime is one additional hop for my transaction. For this I see the need of having session id stored rather than making call to salesforce everytime. So Is there a way I can store id and use it apart from storing in file. I would like explore option on this. What will be best option If its TN ?

Holding on to that key is holding on to the session.

Describe your batching. Earlier you mentioned that you’d send one document. Then at some indeterminate time later you’d send another. This is not consistent with a batch approach.

Can you describe the detailed steps of exactly how you batch the documents to be sent (queue them up) and then once you’re processing the batch, exactly how you envision that working.

Hi Desmat:
I don’t if you are still working on this issue or not. But here is the solution:

You have to get the value of tns1:loginResponse/tns1:result/tns1:serverUrl from the call to ‘login’ webservice to get the serverURL you have to hit. Also to get the sessionId this is waht you have to do:

  1. Create a new document called tns1:SessionHeader and a string, tns1:SessionHeader/tns1:sessionId under it.
  2. Set the value of ‘sessionId’ to whatever you get out of login call.
  3. Convert the tns1:Sessionheader document into a node and add it to the header by using pub.soap.utils:addHeaderEntry service.

That’s it.