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
DoctorDoctor 

Newbie - Query Causing Invalid Session ID error

I am new to working with SOAP.

I am using a cut down version of the Partner WSDL to integratre two salesforce Orgs.

 

I have successfully logged in and ssigned a session Id to the SessionHeader, but when I add a query into the mix, I get an Invalid Session ID error.

 

At the moment I am just playing around to make sure I understand the concepts, so the code isn't as complete as it could be with respect to exception handling and the like.

 

Any ideas where I am going wrong?

 

public with sharing class orgConnectionTest {
    
	public static partnerSoapSforceCom.Soap doLogin(){
		
		partnerSoapSforceCom.Soap myPartnerSoap = new partnerSoapSforceCom.Soap();
	     	partnerSoapSforceCom.LoginResult LoginResult = myPartnerSoap.login('user@domain.com', 'XXXXXXXXXXX');
	 	partnerSoapSforceCom.QueryResult QueryResult = myPartnerSoap.query('SELECT Id from Account LIMIT 1');
	 		 	
	 	myPartnerSoap.endpoint_x = LoginResult.serverUrl;
		partnerSoapSforceCom.SessionHeader_element sh = new partnerSoapSforceCom.SessionHeader_element();
		sh.sessionId = LoginResult.sessionId;

		return null;
		
	}