You need to sign in to do that
Don't have an account?
Wilmer
Looking for a sample of how to consume a SFDC web service by using Scripting Toolkit
Hi everybody,
I need to consume a Salesforce web service (Apex Class) by using Scripting Toolkit. I already have the WSDL of the web service and it's being a long time I don't work with this kind of things so sincerely I´m not sure about how to do that. Could anybody provide me an example of this? I'd appreciate any help.
Thanks.
I need to consume a Salesforce web service (Apex Class) by using Scripting Toolkit. I already have the WSDL of the web service and it's being a long time I don't work with this kind of things so sincerely I´m not sure about how to do that. Could anybody provide me an example of this? I'd appreciate any help.
Thanks.
A call to the WebService should be only 3 lines of code in your "myscript.js" file :
result = sforce.apex.execute('MyWebServiceClass' ,'MyMethod',{theParam:"Something", secondParam:"Something else"});
WScript.echo(result);
ToolKit.Quit();
webService static String MyMethod(String theParam, String secondParam) {
return 'Hello '+theParam;
}
}
All Answers
A call to the WebService should be only 3 lines of code in your "myscript.js" file :
result = sforce.apex.execute('MyWebServiceClass' ,'MyMethod',{theParam:"Something", secondParam:"Something else"});
WScript.echo(result);
ToolKit.Quit();
webService static String MyMethod(String theParam, String secondParam) {
return 'Hello '+theParam;
}
}
You saved my life. I´m gonna test it and let you know soon about its result.
Thanks again and God bless you.
First of all, thanks for you cooperation in this case.
I´ve been trying to run it but seems something is missing 'cause I get the following message:
scriptingtoolkit.wsf(599, 10) msxml3.dll: The system cannot locate the resource specified.
My PC has Windows Vista. Could be that related to the error message? What could I do to fix it?
Thanks again.
I've been tracing the error and it seems to located at line 599 of the connection.js file where it says:
exactly at line 599 = this.connection.send(envelope);
I hope this helps to find an answer. Thanks.
Great, I've just tested it and work perfectly!!!!
Thanks and congratulations, you have a very useful tool and now, better.
Regards,
Wilmer
scriptingtoolkit.wsf(930, 10) JScript Runtime error : 'push' is null or not an object.
It's located at this function:
At line 930.
var arrayParam = value === null ? false : (value.push?true:false);
========
Hope this helps.
This part of code is the same as the one written in the apex.js file (used for scontrols).
The error could be because of the parameters used when calling the execute() method.
Could you please provide the call you are trying to do (parameters used for the execute() call) ?
Thanks,
This way to call the Apex Class works fine in a scontrol.
I tried your code which I truncated a little bit and it is working fine :
The webservice I used for the test :
My previous code is working well because all variables are correctly initialised.
Just replace var Farmacy=""; with var Farmacy;
The variable will be undefined and produce that error.
Ensure all parameters are well defined, with valid (and perhaps not null) values
Message Edited by Artabus on 07-17-2008 12:26 AM
Well, you were right, I wasn't passing any value in the Farmacy parameter. Now I run it and it's really strange because I get the expected response but then another error comes up showing the next message: ERROR: ........... [object Error] (error message located at line 1005 into connection.js file)
And this is the reponse I print:
134839,2,0,2,MY FARMACY (This is the response. An array with some important values into the process).
Now, as you saw, what I try to do is to call the same web service but this time the startingNumber will be set = 134839 in order to continue evaluating a huge table to avoid Apex limits. So I don´t understand why that error is shown in spite of the correct response?
I really appreciate your help in this.
Thanks,
Wilmer
{faultcode:'soapenv:Client', faultstring:''0.2' is not a valid value for the type xsd:int', }
As usual you're right again.
I sincerely want to thank you for your help and support.
I checked the code and added the parseInt function to reset a integer-type variable after receiving the web service response and trying to call it again using the same variable, it was not necessary in a scontrol version but here it is. So now I tested it and work very well.
So, where can I promote this new feature of Scripting Toolkit? because it's a good and efficient solution to save hundreds of hours of coding to call Apex web services from an external tool in Salesforce.
Regards,
Wilmer