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
NiccoDevNiccoDev 

No operation available for request Error message on a Callout

Hi,

I'm trying to make a callout to an external webservice using javascript an apex, but I receive the following error:

 

A problem with the OnClickJavaScript for this button or link was encountered:

{faultcode:'soapenv:Client', faultstring:'No operation available for request {http://soap.sforce.com/schemas/package/ZCMController}doCalc, please check the WSDL for the service.'}

 

The relevant javascript is:

 

var LeadRef="{!Lead.Id}"; 
var iQuoteRef="{!iQuote__c.Id}";

var myvar = sforce.apex.execute("ZCMController","doCalc",{iQuoteid:iQuoteRef,leadid:LeadRef});

 

and it refers to the Apex:

 

public class ZCMController {

public static string doCalc(string iQuoteid,string leadid) {
HttpRequest req = new HttpRequest();
req.setEndpoint('http://acceptance.superdooper.com/endpoint/123');
req.setMethod('POST');
req.setHeader('Content-Type', 'text/xml');
req.setHeader('Connection','keep-alive');
req.setHeader('Content-Length','88');
Http h = new Http();
HttpResponse res = h.send(req);
String result = res.getBody();
return result;
}
}

 

What am I missing?

 

Why is the error message referring to SOAP and WSDL if I'm using REST? 

 

Thanks for your help.

 

Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox

The error isn't coming from your REST call; in fact, you're not even executing your Apex Code at all. The AJAX toolkit (including sforce.apex.execute) runs using SOAP, not REST, regardless of what your Apex Code is doing. You should look here:

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_and_ajax.htm

 

1) The class has to be global, or it won't be visible to outside applications (JavaScript is never considered "part of your package" as far as the API is concerned).

2) The function must be a webservice function, since it is invoked with the API.

 

There is an alternative if you don't necessarily want your class to be global:

 

http://www.salesforce.com/us/developer/docs/pages/Content/pages_js_remoting.htm

All Answers

sfdcfoxsfdcfox

The error isn't coming from your REST call; in fact, you're not even executing your Apex Code at all. The AJAX toolkit (including sforce.apex.execute) runs using SOAP, not REST, regardless of what your Apex Code is doing. You should look here:

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_and_ajax.htm

 

1) The class has to be global, or it won't be visible to outside applications (JavaScript is never considered "part of your package" as far as the API is concerned).

2) The function must be a webservice function, since it is invoked with the API.

 

There is an alternative if you don't necessarily want your class to be global:

 

http://www.salesforce.com/us/developer/docs/pages/Content/pages_js_remoting.htm

This was selected as the best answer
NiccoDevNiccoDev

Thanks!