You need to sign in to do that
Don't have an account?
"Object expected" trying out the StockQuoteSoap example
I am trying to implement the salesforce platform cookbook example to call an external webservice.
Following all the steps in the cookbook everything works fine except for the last part... the HTML part in the S-control.
I past the examplecode in the s-control and saved it ... then i created a web tab with that s-control.
Now, when i hit the tab i get a html/javascript/apex? error which say's "object expected".
If a test a little, the failing line is: var result= sforce.apex.execute("TestCallOut","quote",{symbol:"CRM"});
Has anybody an idea what i could miss/doing wrong?
THE WSDL APEX CLASS
Name | wwwWebservicexNet | ||
Api Version | 14.0 | ||
Status | Active | ||
Is Valid | |||
Body | Download Apex//Generated by wsdl2apex public class wwwWebservicexNet { public class GetQuote_element { public String symbol; private String[] symbol_type_info = new String[]{'symbol','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.webserviceX.NET/','true'}; private String[] field_order_type_info = new String[]{'symbol'}; } public class StockQuoteSoap { public String endpoint_x = 'http://www.webservicex.net/stockquote.asmx'; public Map<String,String> inputHttpHeaders_x; public Map<String,String> outputHttpHeaders_x; public String clientCert_x; public String clientCertPasswd_x; private String[] ns_map_type_info = new String[]{'http://www.webserviceX.NET/', 'wwwWebservicexNet'}; public String GetQuote(String symbol) { wwwWebservicexNet.GetQuote_element request_x = new wwwWebservicexNet.GetQuote_element(); wwwWebservicexNet.GetQuoteResponse_element response_x; request_x.symbol = symbol; Map<String, wwwWebservicexNet.GetQuoteResponse_element> response_map_x = new Map<String, wwwWebservicexNet.GetQuoteResponse_element>(); response_map_x.put('response_x', response_x); WebServiceCallout.invoke( this, request_x, response_map_x, new String[]{endpoint_x, 'http://www.webserviceX.NET/GetQuote', 'http://www.webserviceX.NET/', 'GetQuote', 'http://www.webserviceX.NET/', 'GetQuoteResponse', 'wwwWebservicexNet.GetQuoteResponse_element'} ); response_x = response_map_x.get('response_x'); return response_x.GetQuoteResult; } } public class GetQuoteResponse_element { public String GetQuoteResult; private String[] GetQuoteResult_type_info = new String[]{'GetQuoteResult','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.webserviceX.NET/','true'}; private String[] field_order_type_info = new String[]{'GetQuoteResult'}; } } |
THE APEXCLASS Wrapper
Name | TestCallOut | ||
Api Version | 14.0 | ||
Status | Active | ||
Is Valid | |||
Body | Download Apexglobal class TestCallOut { WebService static String quote(String symbol) { wwwWebservicexNet.StockQuoteSoap stub = new wwwWebservicexNet.StockQuoteSoap(); return stub.GetQuote(symbol); } } |
The S-Control
Label | Generate Stock Quote | Filename | |
S-Control Name | Generate_Stock_Quote | ||
Description | Generate Stock Quote | ||
Type | HTML | ||
HTML Body | <html> <head> <script type="text/javascript" src="/js/functions.js"></script> <script src="/soap/ajax/10.0/connection.js"></script> <script src="/soap/ajax/10.0/apex.js"></script> <script> sforce.debug.trace = true; function stockQuote() { var result= sforce.apex.execute("TestCallOut","quote",{symbol:"CRM"}); document.getElementById('userNameArea').innerHTML = 'Today's CRM Stockquote: '+result; } </script> </head> <body onload=stockQuote()> <div id=userNameArea></div> </body> </html> | ||
Prebuild In Page |
Streepeye,
First thing to do would be to try this in Firefox, then when you get the error, go to Tools->Error Console. This should give you a more comprehensible error to work with than the Internet Explorer one. I just looked at the target web service and it does appear to be up and running.
Hope this helps,
C.
ok, thanks,
going to try that...
Thanks a Lot !
That helped dramaticly !!
a single quote in the phrase: today's CRM stockquote....etc broke my string !
pffffff ... what a mistake to make .... sorry.