You need to sign in to do that
Don't have an account?

WSC - Setting session id and server URL after calling login()
Hello, after calling login() and try making a call, say query(), I get the following error:
exceptionMessage='Destination URL not reset. The URL returned from login must be set in the SforceService'
According to the SOAP API documentation for login() it says the following:
After logging in, a client application needs to perform these tasks:
- Set the session ID in the SOAP header so that the API can validate subsequent requests for this session.
- Specify the server URL as the target for subsequent service requests. You must change to the server URL, the login server only supports login calls.
How is this done when using the force.com WSC? All the examples I've seen set the username and password in the ConnectorConfig. I see there's a setSessionHeader() in PartnerConnection but I don't see any method to set the server url.
Can someone point me in the right direction?
If you turn on manualLogin then its upto you to handle updating the stub after login, but you can just do
PartnerConnection conn = Connector.newConnection(username, password);
and it'll automatically do login and setup serverUrl/sessionId for you. (there's a version of newConnection that takes a ConnectorConfig if you have a non-default config you want to use)
All Answers
WSC should do this for you, can you post a sample of your code that ends up with this error?
Hi Simon,
My code looks something like this:
If you turn on manualLogin then its upto you to handle updating the stub after login, but you can just do
PartnerConnection conn = Connector.newConnection(username, password);
and it'll automatically do login and setup serverUrl/sessionId for you. (there's a version of newConnection that takes a ConnectorConfig if you have a non-default config you want to use)
If for some reason you need to manually set the serverUrl, then i beleive its setServiceEndpoint() on the Config object.
Thanks Simon for the info!