You need to sign in to do that
Don't have an account?
arigela
Write test method for session Id
Hi,
Can you please help any one to test the below code.
Note: I am creating test user, and test mock callout in my test class, but getting null pointer exception on when getting sessionId.
request.setBody('<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Header/><Body><login xmlns="urn:partner.soap.sforce.com"><username>' + '<userName>' + '</username><password>' + '<Password>' + '</password></login></Body></Envelope>');
Dom.XmlNode resultElmt = (new Http()).send(request).getBodyDocument().getRootElement()
.getChildElement('Body','http://schemas.xmlsoap.org/soap/envelope/')
.getChildElement('loginResponse','urn:partner.soap.sforce.com')
.getChildElement('result','urn:partner.soap.sforce.com');
String sessionId = resultElmt.getChildElement('sessionId','urn:partner.soap.sforce.com').getText();
Thanks
Venkat
Can you please help any one to test the below code.
Note: I am creating test user, and test mock callout in my test class, but getting null pointer exception on when getting sessionId.
request.setBody('<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Header/><Body><login xmlns="urn:partner.soap.sforce.com"><username>' + '<userName>' + '</username><password>' + '<Password>' + '</password></login></Body></Envelope>');
Dom.XmlNode resultElmt = (new Http()).send(request).getBodyDocument().getRootElement()
.getChildElement('Body','http://schemas.xmlsoap.org/soap/envelope/')
.getChildElement('loginResponse','urn:partner.soap.sforce.com')
.getChildElement('result','urn:partner.soap.sforce.com');
String sessionId = resultElmt.getChildElement('sessionId','urn:partner.soap.sforce.com').getText();
Thanks
Venkat
Can you post the code of the mock callout class? It's hard to see what's going wrong without that code and especially the returned xml message.
Thanks.
Regards,
Martijn Schwärzer