2

I need to get some info via SOAP calls and I stick with one error. Right now I need to support two ways of sending SOAP calls:

  1. making a call with username-password params
  2. making a request with permanent token within the SOAP header (without providing user name and password)

The first case is working fine. Here is a sample:

ConnectorConfig partnerConfig = new ConnectorConfig();
partnerConfig.setUsername(userName);
partnerConfig.setPassword(password);
partnerConfig.setAuthEndpoint("https://" + instanceUri + "/services/Soap/u/27.0");
partnerConfig.setRestEndpoint("https://" + instanceUri + "/services/data/v27.0");
partnerConfig.setPrettyPrintXml(true);
PartnerConnection partnerConnection = new PartnerConnection(partnerConfig);
DescribeGlobalResult global = partnerConnection.describeGlobal();   

global object is returned successfully.

Then I tried to do this via SOAP headers. Here is my code:

ConnectorConfig partnerConfig = new ConnectorConfig();
partnerConfig.setServiceEndpoint("https://" + instanceUri + "/services/Soap/u/27.0");
partnerConfig.setSessionId(soapToken);
partnerConfig.setManualLogin(true);//to prevent login() for partnerConnection 
partnerConfig.setAuthEndpoint("https://" + instanceUri + "/services/Soap/u/27.0");
partnerConfig.setRestEndpoint("https://" + instanceUri + "/services/data/v27.0");
partnerConfig.setPrettyPrintXml(true);
PartnerConnection partnerConnection = new PartnerConnection(partnerConfig);
partnerConnection.setCallOptions(soapToken, null);
DescribeGlobalResult global = partnerConnection.describeGlobal();

in this case I'm getting

UnexpectedErrorFault [ApiFault  exceptionCode='INVALID_SESSION_ID' exceptionMessage='Invalid Session ID found in SessionHeader: Illegal Session'

error after partnerConnection.describeGlobal();

Can someone help me in this question? Maybe I missed something.

Regards, Eugene

1
  • The session id is what you get back from salesforce which lets you connect without specifying the username and password. You appear to be setting it partnerConfig.setSessionId(soapToken); but where is the value of soapToken being populated in the first place?
    – Doug B
    Jun 25 '13 at 19:21
1

If by permanent token you mean an OAUth refresh token, then you can not make API calls directly with the refresh token, instead you use the refresh token to get a new access token an use that to call the API (passing the access token in the same way you'd pass a sessionId)

1
  • Thank. I will try to get more details about token that I have. Any way thank for your help!
    – E_Gurin
    Jun 26 '13 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.