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
ABCDEFGHIJKLMNOABCDEFGHIJKLMNO 

Development vs. Production Org: INVALID_SESSION_ID: Invalid Session ID found in SessionHeader

I have a C# application that calls an Apex webservice that I built in a dev org, packaged, and installed in our production org.

 

The webservice has an 87% test coverage score. The application has been thoroughly tested against the dev org. I created a user in the production org and given that user the exact same rights (as far as I can tell) that I had in my dev org.

 

When I run the application in our production org, it fails whenever it calls the webservice with the "INVALID_SESSION_ID: Invalid Session ID found in SessionHeader" error.

 

Please note that this is the identical code in both orgs. The only difference is in the user that makes the call.

 

What's going on?

 

TIA,

 

John

Best Answer chosen by Admin (Salesforce Developers) 
ABCDEFGHIJKLMNOABCDEFGHIJKLMNO

Sorry for the cross-post, I realized that this was no longer a .Net question and thought it should be in a different forum.

 

Thanks for the help.

All Answers

ABCDEFGHIJKLMNOABCDEFGHIJKLMNO

Another difference has emerged -- the application was developed against the partner.wsdl but our production org is Enterprise.

 

Does this make a difference?

SuperfellSuperfell
it sounds like you're using a custom web service written in apex. note that the URL's in the WSDL for these are organization specific, so you'll need to udpate the URL, based on the value in the WSDL in your production organization.
ABCDEFGHIJKLMNOABCDEFGHIJKLMNO

I'm not quite sure I understand you. Are you saying that I need to generate a new WSDL from the webservice class in my production org, bind that to my application, and rebuild that application?

 

If that is so, how do I create a webservice that works with any organization? We want to put this application on AppExchange and obviously this won't work for our customers.

 

TIA,

 

John

ABCDEFGHIJKLMNOABCDEFGHIJKLMNO

bump

 

I have an Apex webservice that I developed in one org that I cannot run in another org. I can install it, but I cannot run it.

 

Is it possible to create a single Apex web service that can be installed and run in any org that supports such webservices? If so, how? If not, why not?

SuperfellSuperfell
You will have to update the host name part of the apex webservice URL based on the user/org (you can get the host name from the serverUrl from login)
ABCDEFGHIJKLMNOABCDEFGHIJKLMNO

Sorry for the cross-post, I realized that this was no longer a .Net question and thought it should be in a different forum.

 

Thanks for the help.

This was selected as the best answer
JPClarkJPClark

Simon gave a clue to the answer. I'm posting some code that fixed this issue in a read-only property I placed in my interface class:

 

public i360ForceLogin.GlobalWebServices.GlobalWebServicesService GlobalWebServices { get { i360ForceLogin.GlobalWebServices.GlobalWebServicesService gws = new i360ForceLogin.GlobalWebServices.GlobalWebServicesService(); //Inorder to use the existing login, get the session ID i360ForceLogin.GlobalWebServices.SessionHeader header = new i360ForceLogin.GlobalWebServices.SessionHeader(); header.sessionId = this.ForceServer.SessionHeaderValue.sessionId; //This is a tricky part that isn't documented: string loURL = this.ForceServer.Url; loURL = loURL.Substring(0, loURL.IndexOf("service")); string wsURL = gws.Url; wsURL = wsURL.Substring(wsURL.IndexOf("service")); //Need to change the URL for the web service or it attempts to connect // to the original URL that created the WSDL gws.Url = loURL + wsURL; // Examples: Top is from the currently logged in server (loURL) // Bottom is from the created GlobalWebService //https://na6-api.salesforce.com/services/Soap/c/16.0/00F10000000ZyKk //https://na7-api.salesforce.com/services/Soap/class/MyWebService gws.SessionHeaderValue = header; return gws; } }

 

 

I can then call the methods on the returned apex class (proxy).

 

 

hamayoun65hamayoun65

JPClark,

 

YOU ROCK!!!!!!!