I have created a webservice class in Salesforce Org B (destination).
The purpose of this webservice is to accept values and create a custom object record in Org B.
I generated partner WSDL from Org B and imported into in my Org A (my Source Salesforce Org).
I generated WSDL for my webservice class from Org B and again imported into my Org A (it created two classes)
After adding the remote site settings I wanted to testdrive sending data from Org A to Org B.
This is the code snippet that I tried it in anon apex.
partnerSoapSforceCom.Soap p = new partnerSoapSforceCom.Soap();
String uname = 'UNAME';
String pwd = 'PWD+TOKEN';
partnerSoapSforceCom.LoginResult e = p.login(uname,pwd);
System.debug('The result of the login call is => '+e);
System.debug('ServerURL = '+e.serverURL);//Line 1
System.debug('Session Id = '+e.SessionId);//Line 2
soapSforceComSchemasClassCreateRec.rec rm = new soapSforceComSchemasClassCreateRec.rec();
rm.documentdate = '2016-02-25 00:00:00';
rm.documentid = '1';
rm.Name = 'Test';
soapSforceComSchemasClassCreateRec.rec rd1 = new soapSforceComSchemasClassCreateRec.rec();
rd1.createDocument(rm);
I am able to make a successful handshake and get serverurl and sessionId (Line 1 & Line 2).
After authentication, I am trying to invoke the actual webservice method for creating record and I am getting the following error as below.
I believe it is because I have not set the session Id which I received from Line 2 during the actual invocation.
Can someone tell me how do I actually set the session Id in my request ?