function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MascotteMascotte 

INVALID_SESSION_ID

Problem when working with sforce API:
INVALID_SESSION_ID found in SessionHeader

Here is the code I use to login:

Code:
LoginResult loginResult = S.login(login, pass);
S.SessionHeaderValue = new SessionHeader();
S.SessionHeaderValue.sessionId = loginResult.sessionId;
S.Url = loginResult.serverUrl;

 Any news concerning this problem ?
The Support Service couldn't resolve my problem :s

Gareth DaviesGareth Davies
Code:
//execute the login placing the results  
//in a LoginResult object 
this.username=username;
LoginResult loginResult = binding.login(username, password); 

//set the session id header for subsequent calls 
binding.SessionHeaderValue = new SessionHeader(); 
binding.SessionHeaderValue.sessionId = loginResult.sessionId; 

//reset the endpoint url to that returned from login 
binding.Url=loginResult.serverUrl;
 
This is the login code from developer's Sidekick which look just like yours and works fine. Where and when exactly do you receive the error message? 
 
 When I have seen the error message you describe, it is when a session has gone stale and timed out.
 
Gareth.
MascotteMascotte
Thank you for your response...

I use this code in ASP.Net applications.
When connecting the first time it works fine.
If there is a new connection after a short time,
using the same sforce account, I get this message
on the first action query() or create() ...

I hope you understood my poor english ^^

Best regards,
Matthias.
MascotteMascotte
I forget to say that it works perfectly earlier !
Gareth DaviesGareth Davies
Ce n'est aucun problème mon ami que je comprends tout que vous écrivez, mais je ne suis pas sûr je peux résoudre votre problème.
 
What about ensuring that you have a "new" S declared  - S = new SforceService incase there is something in that object.
 
Other than that, could it be a Session variable between Postbacks of the ASP.NET reverting to a previous session values?  or, conversly, that the on-pageload event overwrites the current one and resets it to a pre-initialised state?
 
G.
MascotteMascotte
Happy to be understood ^^

Thank you for your help. I'll check if it is an ASP.net session problem.