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
ClintClint 

Accessing Apex webService Classes: Invalid Session Id

I'm new to salesforce and having been trying to access some Apex webServices. I've downloaded the php toolkit and both the partner and integration wsdls, and tried to access a simple method called "subscribe", which gave me a "INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session" error.

Looking about a bit I discovered it was necessary to get a session id first, which I am able to do via the partner wsdl and the "login" method. I then tried setting the sessionId for a new connection via a setSessionHeader call, but when I try and call the "subscribe" method again, I get the same invalid session error.

I am posting a bit of code to illustrate what I'm referring to below.

Code:
$mySforceConnection = new SforcePartnerClient();
$mySoapClient = $mySforceConnection->createConnection("includes/salesforce/soapclient/partner.wsdl.xml");
$mylogin = $mySforceConnection->login("username", "passandtoken");

$mySforceConnection2 = new SforcePartnerClient();
$mySoapClient2 = $mySforceConnection2->createConnection("includes/salesforce/integration.wsdl");
$mySforceConnection2->setSessionHeader($mylogin->sessionId);

Any tips, pointers or help would be greatly appreciated... thanks!
ClintClint
For those who may be having the same problem, I ultimately resolved this with help from Simon, in an Apex forum thread