You need to sign in to do that
Don't have an account?
Apex WSDL: login/URL issue
I need to call the compileandtest function.
I use the following code to login (note the username/password are from a sandbox)
ApexWSDL wsdl = new ApexWSDL();
SforceService sforce = new SforceService();
LoginResult result = sforce.login(Username, Password);
SessionHeader sh = new SessionHeader();
sh.sessionId = result.sessionId;
wsdl.SessionHeaderValue = sessionHeader;
If I do NOT set the URL, it leaves it set to: https://cs1-api.salesforce.com/services/Soap/s/17.0
and when I make the call CompileAndTest, it throws the following error:
INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session. Session not found, missing session key
If I set it by using the following:
wsdl.Url = result.serverUrl;
/*
* results in:
* https://tapp0-api.salesforce.com/services/Soap/u/17.0/00DT0000000Gg4n
*/
OR
wsdl.Url = result.metadataServerUrl;
/*
* results in:
* https://tapp0-api.salesforce.com/services/Soap/m/17.0/00DT0000000Gg4n
*/
Then when I make the call CompilAndTest it throws the following error:
"No operation available for request {http://soap.sforce.com/2006/08/apex}compileAndTest"
can somebody help here?
All Answers
What do you mean by cs1?
The above example does NOT work.
Using the same credentials:
https://tapp0.salesforce.com/home/home.jsp
So your saying you need a seperate WSDL from sandbox and a seperate WSDL for live/prod?
Or just a new instance of each WSDL for each environment/sandbox?
Cheers SimonF,
For others with similar issue, the following code sets the Url:
Uri defaultUrl = new Uri(wsdl.Url); Uri sessionUrl = new Uri(sforce.Url); string targetUrl = "http://" + sessionUrl.Host + defaultUrl.PathAndQuery; wsdl.Url = targetUrl;
HA! Good point.
Hence why its always good to have two eyes on the code :p