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
MaverickDevMaverickDev 

NVALID_SESSION_ID using partner/enterprise wsdl for two different SF users

Hi,

 

I followed example given on this link : http://wiki.developerforce.com/page/Force.com_for_ASP.NET_Developers

it worked perfectly for my SF developer account.

 

But when I tried the same with different SF credentials without changing web service reference (as other account also had apex web service methods to pull leads detail) it gave me below error (I passed correct username, password with access token for both users).

 

INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session. Session not found, missing session key:

 

My question is  : how can my .NET app authenticate multiple SF users using same WSDL file?

If not then what is the other way around?

 

Thanks in advance!!

Best Answer chosen by Admin (Salesforce Developers) 
MaverickDevMaverickDev

Finally I got it!!

 

LoginResult lr = sforcebinding.login(_userId, _passwordWithToken);

......

......

int index1 = lr.serverUrl.IndexOf(@"/services/");
int index2 = getLeadInfo.Url.IndexOf(@"/services/");
if (index1 == 0 || index2 == 0)
    {
        Response.Write("Invalid URL in bindings");
        return;
     }
getLeadInfo.Url = lr.serverUrl.Substring(0, index1) + getLeadInfo.Url.Substring(index2);

All Answers

SuperfellSuperfell

If you're calling a custom apex web service, then you'll need to update the Url property with the instnace/hostname of the current user, as it'll contian the instance url of the user that originally downloaded in the wsdl.

MaverickDevMaverickDev

Thanks Simon,

 

Can  you provide me more info of the same. Any article with example would be very helpful!?

MaverickDevMaverickDev

Finally I got it!!

 

LoginResult lr = sforcebinding.login(_userId, _passwordWithToken);

......

......

int index1 = lr.serverUrl.IndexOf(@"/services/");
int index2 = getLeadInfo.Url.IndexOf(@"/services/");
if (index1 == 0 || index2 == 0)
    {
        Response.Write("Invalid URL in bindings");
        return;
     }
getLeadInfo.Url = lr.serverUrl.Substring(0, index1) + getLeadInfo.Url.Substring(index2);

This was selected as the best answer