function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
StreepeyeStreepeye 

"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

 

NamewwwWebservicexNet  
Api Version14.0  
StatusActive  
Is ValidChecked  
BodyDownload 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

 

NameTestCallOut  
Api Version14.0  
StatusActive  
Is ValidChecked  
BodyDownload Apex
global class TestCallOut {
WebService static String quote(String symbol) {
wwwWebservicexNet.StockQuoteSoap stub =
new wwwWebservicexNet.StockQuoteSoap();
return stub.GetQuote(symbol);
}
}

 

 

The S-Control

 

LabelGenerate Stock QuoteFilename 
S-Control NameGenerate_Stock_Quote  
    
DescriptionGenerate Stock Quote
TypeHTML  
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 PageChecked

 

 

 

 

 

 

Message Edited by Streepeye on 01-26-2009 02:18 PM
Message Edited by Streepeye on 01-26-2009 02:20 PM
Message Edited by Streepeye on 01-26-2009 02:20 PM
Message Edited by Streepeye on 01-26-2009 02:22 PM
CaffeineCaffeine

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.

Message Edited by Caffeine on 01-26-2009 05:32 PM
StreepeyeStreepeye

ok, thanks,

going to try that...

 

 

StreepeyeStreepeye

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. 

 

Message Edited by Streepeye on 01-26-2009 02:53 PM