+ Start a Discussion

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();

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


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?