+ Start a Discussion
kent.chenkent.chen 

Help! How to set session-id when calling an APEX Web Service?

Hi, this problem has been driving me crazy. Please help! 

 

I had an APEX class which had a web service method called "makeSth()"

And I need to call it from another application.

What I did was to generate the stub from this Apex class's  WSDL using WSC.  Then write the client code as following:

 

 

ConnectorConfig config = new ConnectorConfig();
config.setUsername(getUserName());
config.setPassword(getPassword());
config.setTraceMessage(true);

//SoapConnection and Connector are both stub classes 
SoapConnection conn = Connector.newConnection(config); conn.makeSth("sth");

 

When I run it, what I got was "INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session". 

 

Of course I would got that because the session-id was not set  (<sessionId xsi:nil="true" /> in SOAP request )

And session-id was not set because no login had been done yet. 

 

So what should I do?   How should I login?   

 

Vanessa BarrosVanessa Barros

Hii! i have the same.. you are calling salesforce to salesforce?