You need to sign in to do that
Don't have an account?

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="http://soap.sforce.com/schemas/class/TestWebService" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://soap.sforce.com/schemas/class/TestWebService">
<types>
<xsd:schema elementFormDefault="qualified" targetNamespace="http://soap.sforce.com/schemas/class/TestWebService">
<xsd:element name="DebuggingInfo">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="debugLog" type="xsd:string"/>
</xsd:sequence>
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 = 'https://ap1-api.salesforce.com/services/Soap/class/TestWebService';
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=http://soap.sforce.com/schemas/class/TestWebService';
private String DebuggingInfo_hns = 'DebuggingInfo=http://soap.sforce.com/schemas/class/TestWebService';
private String CallOptions_hns = 'CallOptions=http://soap.sforce.com/schemas/class/TestWebService';
private String DebuggingHeader_hns = 'DebuggingHeader=http://soap.sforce.com/schemas/class/TestWebService';
private String SessionHeader_hns = 'SessionHeader=http://soap.sforce.com/schemas/class/TestWebService';
private String[] ns_map_type_info = new String[]{'http://soap.sforce.com/schemas/class/TestWebService', '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);
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'',
'http://soap.sforce.com/schemas/class/TestWebService',
'testWebMethod',
'http://soap.sforce.com/schemas/class/TestWebService',
'testWebMethodResponse',
'TestWebServiceStub.testWebMethodResponse_element'}
);
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
Thanks
Vasu