function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AshanAshan 

Problem In Invoking Apex Web Service From (SOAP) Java

I get the error [INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session] when i try ro call a Apex Web Service as following with JAVA.

 

ConnectorConfig config = new ConnectorConfig();
config.setUsername(userId);
config.setPassword(passwd);   
SoapConnection connection = Connector.newConnection(config);

connection.MyWebServiceMethod();

 

This method works fine for Enterprise WSDL

 

 

Best Answer chosen by Admin (Salesforce Developers) 
dkadordkador

You need to use the enterprise or partner API to login first and get a session ID.  Then once you have it, set it on the SoapConnection stub.  SoapConnection won't login by default like EnterpriseConnection or PartnerConnection.

 

You can also use oauth2 to get a session ID.

All Answers

dkadordkador

You need to use the enterprise or partner API to login first and get a session ID.  Then once you have it, set it on the SoapConnection stub.  SoapConnection won't login by default like EnterpriseConnection or PartnerConnection.

 

You can also use oauth2 to get a session ID.

This was selected as the best answer
AshanAshan
Thanks dkador, This solves the problem
goabhigogoabhigo

Hi,

 

Could you post the working code that you used for calling web service method?