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

Invalid Session ID found in SessionHeader: Illegal Session faultcode=INVALID_SESSION_ID faultactor

Hi All,


I am Also suffer from same Situation (Exchange Data from Sales force Organization 1 to Sales force Organization 2 )

I wrote Apex class for SF Org1 has  TestWebService class.

I want  get data from SF Org1 to SF Org2 by using webservice methods in Apex class in SF Org1  and that class generates WSDL file and upload WSDL file into SF Org2 and it generate Stub class from WSDL file.


Apex class for SF Org1 has one web method below


global class TestWebService{   
    webService static String testWebMethod(String testname ){
        return 'Hello '+testname;


And Generated WSDL file from above class called TestWebService


<?xml version="1.0" encoding="UTF-8"?>
 Web Services API : TestWebService
<definitions targetNamespace="" xmlns:xsd="" xmlns="" xmlns:soap="" xmlns:tns="">
  <xsd:schema elementFormDefault="qualified" targetNamespace="">
   <xsd:element name="DebuggingInfo">
      <xsd:element name="debugLog" type="xsd:string"/>



I deployed wsdl  file into Another SF Org2  it generates Stub class from above wsdl file called TestWebServiceStub




public classs public TestWebServiceStub {


public class TestWebService {
        public String endpoint_x = '';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        public Integer timeout_x;
        public TestWebServiceStub.AllowFieldTruncationHeader_element AllowFieldTruncationHeader;
        public TestWebServiceStub.DebuggingInfo_element DebuggingInfo;
        public TestWebServiceStub.CallOptions_element CallOptions;
        public TestWebServiceStub.DebuggingHeader_element DebuggingHeader;
        public TestWebServiceStub.SessionHeader_element SessionHeader;
        private String AllowFieldTruncationHeader_hns = 'AllowFieldTruncationHeader=';
        private String DebuggingInfo_hns = 'DebuggingInfo=';
        private String CallOptions_hns = 'CallOptions=';
        private String DebuggingHeader_hns = 'DebuggingHeader=';
        private String SessionHeader_hns = 'SessionHeader=';
        private String[] ns_map_type_info = new String[]{'', 'TestWebServiceStub'};
        public String testWebMethod(String testname) {
            TestWebServiceStub.testWebMethod_element request_x = new TestWebServiceStub.testWebMethod_element();
            TestWebServiceStub.testWebMethodResponse_element response_x;
            request_x.testname = testname;
            Map<String, TestWebServiceStub.testWebMethodResponse_element> response_map_x = new Map<String, TestWebServiceStub.testWebMethodResponse_element>();
            response_map_x.put('response_x', response_x);
              new String[]{endpoint_x,
            response_x = response_map_x.get('response_x');
            return response_x.result;







 And I wrote controller in SF Org2 ,  Access  SF Org1 from TestWebService class  in that method testWebMethod(String testname)


Controller in SF Org2


 TestWebServiceStub.TestWebService testStub = new TestWebServiceStub.TestWebService();

testStub.inputHttpHeaders_x = new Map<String, String>();


testStub.inputHttpHeaders_x.put('Authorization','Basic YXJ1bmFAYm9kaHRyZWUuY29tOmJvZGh0cmVlMTIzVW9RSFJPVFBaWjRWcko3NUZrWFg0TUJEeA==');  


Here I Provided Encode 63 bit code is ---        username:passwordsecurtytoken        



String nameresp = testStub.testWebMethod('Hi Hello ');





I got I Exception Called  InValid SessionHeader and System.callout Exception


Can u any give a solutions for this