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
ryanhcaryanhca 

"No service available for class" error message ?

After trying to execute the "webServiceName" web service below, I get this error:

ERROR: ........... {faultcode:'soapenv:Client', faultstring:'No service available for class 'MyClass'', }

 

Here's my button code:

 

{!requireScript("/soap/ajax/16.0/connection.js")}
{!requireScript("/soap/ajax/16.0/apex.js")}

var args = {
objId:'{!MasterObject__c.Id}',
childIds:{!GETRECORDIDS($ObjectType.ChildObject__c)}
};

function callback(result) { location.href=result.pagereference; }

var result = sforce.apex.execute('MyClass', 'webServiceName', args, callback);

 

 

 

Here's my service code:

 

global with sharing class MyClass
webservice static wsResult webServiceName(String objId, String[] childIds) {
// Do stuff...

wsResult result = new wsResult();
result.pagereference = pr.getUrl();
result.success = true;
result.errorCode = 0;
result.errorMsg = '';
return result;
}

global class wsResult {
webservice string pagereference;
webservice boolean success;
webservice Integer errorCode;
webservice String errorMsg;

public wsResult() {}

public wsResult(string url, boolean result, Integer code, String msg) {
this.pagereference = url;
this.success = result;
this.errorCode = code;
this.errorMsg = msg;
}
}

 

 I looked in my Enterprise WSDL, and couldn't find my service -- but I'm a complete novice with WSDLs...

 

 

 Thanks in advance!

Best Answer chosen by Admin (Salesforce Developers) 
Ron WildRon Wild

Is the webservice in a package?  You'll need to add the package prefix to the name of the class if it is.   I think for a package  "mypkg" it would be

 

var result = sforce.apex.execute('mypkg/MyClass', 'webServiceName', args, callback);

 

You might also try doing the call without the callback.  e.g.

var result = sforce.apex.execute('mypkg/MyClass', 'webServiceName', args, null, false);

All Answers

Ron WildRon Wild

You have "with sharing" in the class definition ... maybe the user you're seeing the error for hasn't been granted access to your class?

 

Ron

ryanhcaryanhca

Nope. :(

 

Running this as the administrator user -- and removed "with sharing". 

Ron WildRon Wild

Is the webservice in a package?  You'll need to add the package prefix to the name of the class if it is.   I think for a package  "mypkg" it would be

 

var result = sforce.apex.execute('mypkg/MyClass', 'webServiceName', args, callback);

 

You might also try doing the call without the callback.  e.g.

var result = sforce.apex.execute('mypkg/MyClass', 'webServiceName', args, null, false);
This was selected as the best answer
ryanhcaryanhca

Still nothing. 

 

Error message is still:

 

"No service available for class 'mypkg.MyClass__c'"

ryanhcaryanhca

Worked! 

 

In my original code, I had accidentally left off the "__c" in the web service name. I had "fixed" it, but then tried removing it and now it works.

 

So the AJAX call is:

 

 

{!requireScript("/soap/ajax/16.0/connection.js")}

{!requireScript("/soap/ajax/16.0/apex.js")}

 

var args = {

objId:'{!mypkg__MasterObject__c.Id}',

childIds:{!GETRECORDIDS($ObjectType.mypkg__ChildObject__c)}

};

 

var result = sforce.apex.execute('mypkg/MyClass', 'webServiceName', args, null, false);

location.href=result.pagereference;

 

 

 

Message Edited by ryanhca on 08-10-2009 08:42 PM
commercial coecommercial coe
External system getting the below error message, Can anyone please let me know the reason for that. The Webservice class which generated WSDL file is not inside the package. But the other utility class is inside the package.

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Body>
    <soapenv:Fault>
      <faultcode>soapenv:Client</faultcode>
      <faultstring>No service available for class 'XX_XXX_Event_Processing_Web_Service.'</faultstring>
    </soapenv:Fault>
  </soapenv:Body>
</soapenv:Envelope>