1

First of all, Wish you a very happy new year. :)

I have an issue in assigning Session id while I am trying to login to another salesforce org using SOAP API. Here is the code.

partnerSoapSforceCom.Soap sp = new partnerSoapSforceCom.Soap();

String username = 'username';
String password = 'password';

partnerSoapSforceCom.LoginResult loginResult = sp.login(username, password);

soapSforceCom200608Apex.Apex apexWebSvc = new soapSforceCom200608Apex.Apex();
soapSforceCom200608Apex.SessionHeader_element ses = new soapSforceCom200608Apex.SessionHeader_element();
ses.SessionId = loginResult.sessionId;

apexWebSvc.timeout_x = 120000;
apexWebSvc.SessionHeader = sessionHeader;

I see no error in the code. But dev console throws unexpected token '=' error for every statement from ses.SessionId = loginResult.sessionId; statement.

Can anyone please let me know where I am missing the point.

Note. All WSDLs and apex soap api related classes are successfully generated without any compilation erros.

1 Answer 1

2
SessionHeader.sessionId = loginResult.sessionId;

this should give you the session Id and set the course. Thus the code should turn out to be :

partnerSoapSforceCom.Soap sp = new partnerSoapSforceCom.Soap();

String username = 'username';
String password = 'password';

partnerSoapSforceCom.LoginResult loginResult = sp.login(username, password);

soapSforceCom200608Apex.Apex apexWebSvc = new soapSforceCom200608Apex.Apex();
soapSforceCom200608Apex.SessionHeader_element ses = new soapSforceCom200608Apex.SessionHeader_element();
sessionHeader.sessionId = loginResult.sessionId;
apexWebSvc.SessionHeader = sessionHeader;
2
  • 1
    Amit -- you might want to clean up your answer and eliminate those <br/> to avoid confusing some apex newbie
    – cropredy
    Mar 8, 2015 at 1:57
  • 1
    I removed the br tags - couldn't stand looking at them ;-)
    – metadaddy
    Mar 8, 2015 at 2:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .