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
npat6npat6 

UserInfo.getSessionId () returning null for site user

We have a site for our customers to use to view their accounts / bill / update their details / etc.  As part of the site we have a wizard where the customer can sign up as a user (the public user for the site has access to those pages).

On submission of the last page in the wizard, there is a webservice call back to Salesforce to create the user (I believe it was done this way due to restrictions in creating a user).

This whole process is currently working successfully in production, however, our testers needed to setup some users in our Test sandbox and we are getting the following error in the Test environment:
EXCEPTION_THROWN|[63]|System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session faultcode=sf:INVALID_SESSION_ID faultactor=

The code at line 63 is just a WebServiceCallout.invoke.

The session Id is set in the controller with the following code:
PortalUtil_WS.PortalUtil stub = new PortalUtil_WS.PortalUtil();
stub.SessionHeader = new PortalUtil_WS.SessionHeader_element();
stub.SessionHeader.sessionId = UserInfo.getSessionId();

The Test sandbox is on CS5 (winter 15), but I have also tested the process in our Training sandbox which is on CS6 (Summer 14) and the same error is occuring there.

I'm not sure how long this has been happening because we haven't tested this process for a little while and it hasn't been modified in several months either.

Best Answer chosen by npat6
tlfutlfu
I found this information on Salesforce Stackexchange: http://salesforce.stackexchange.com/questions/48903/session-expired-or-invalid-problem-calling-an-restresource-from-apex-in-winte. Apparently this is an undocumented security fix, and not a bug, according to Salesforce.

All Answers

tlfutlfu
I am observing this in the Winter '15 sandbox also. This is an urgent issue for us. We are also using this method so that we can make a web service call to an Apex web service. I'm opening an urgent case with Salesforce support on this.
tlfutlfu
I found this information on Salesforce Stackexchange: http://salesforce.stackexchange.com/questions/48903/session-expired-or-invalid-problem-calling-an-restresource-from-apex-in-winte. Apparently this is an undocumented security fix, and not a bug, according to Salesforce.
This was selected as the best answer
npat6npat6
Thanks for the response.  Premier support has confirmed the same thing and that they're looking at adding it to the documentation - hopefully it's not too late for other customers...
tlfutlfu
FYI, this security fix was rolled-back earlier this week (on or around 10/1) to the pre-Winter '15 behavior. We complained strongly enough and loudly enough to Salesforce that this undocumented change had a significant impact on our application. With the combination of the Winter '15 blackout period, and Dreamforce coming up, we weren't going to have time to adequately test a workaround before Winter '15 goes GA.