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
mangiamangia 

S-Control fails to call Web Service - No service available for class 'myWSApi",

S-Control:
var result  = sforce.apex.execute('myApiWs', 'Xlogin', {customer:'SF', login:'Bob', pw:'Smith'});
 
Code:
global class myApiWs
{
    WebService static String Xlogin(String customer, String login, String pw)
    {
        return 'Customer=' + customer + '  Login=' + login;
    }
}
 
I have an S-Control that yields the error "No service available for class 'myApiWS", " when an attempt is made to call this Web Service.  Any idea why?
 
Chris
Best Answer chosen by Admin (Salesforce Developers) 
AkiTAkiT
Agree that it could be highlighted better. Just struggled with the issue - luckily found another post on the topic.

Those who need help: you need to prefix class with namespace: YourNamespace.YourClass

All Answers

mangiamangia

Same error attempting to call the sample HelloWorld2 web service from the sample HelloWorld S-Control!!!  

 .... faultstring:'No service available for class 'HelldWorld2", }

Is there some sort of developer account setting that expires?  All this code use to work fine...

Chris

<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>
function demo()
{
   try
   {
       // The apex.execute() command in the AJAX Toolkit
       // allows the s-control to access the specified
       // Apex class and method.

       var result = sforce.apex.execute('HelloWorld2' , 'sayHelloWorld', {arg:"new Apex user!"});

       document.getElementById('userNameArea').innerHTML = 'Congratulations! ' + result;
   }
   catch(error)
   {
       alert(error);
   }
}
</script>
</head>
<body onload=demo()>
    <div id=userNameArea>
    </div>
</body>
</html>

global class HelloWorld2 {
 // The WebService keyword makes this a public
 // WebService method. WebService methods must
 // always be static, and must also be contained
 // in a global class.

 WebService static String sayHelloWorld(String arg) {
  return 'Hello ' + arg;
 }

 // The following is a simple unit test for the
 // sayHelloWorld method. Unit test methods take
 // no arguments, commit no data to the database,
 // and are flagged with the testMethod keyword
 // in the definition.

 static testMethod void testHelloWorld() {
  System.assertEquals('Hello to you!', sayHelloWorld('to you!'));
 }
}

Ron HessRon Hess
this code does work on my developer edition

i'm not sure what is going on, but your developer edition may have some permissions or settings which are defeating this otherwise correct code.

do you see the WSDL link for this class when you view the apex code details list in the setup-build area?
mangiamangia

Yes I have Edit, Del, WSDL, Security links next to all my Apex Code.  Security is set to System.Administrator.

Don't know if or how this could be related, but last week I àGranted Login Accessà to SF support to assist me on publishing my application.

Chris

Ron HessRon Hess
did you by chance add a namespace?
mangiamangia

Nope, there is no namespace.  The code looks pretty much is as I have posted.

This most be some sort of Developer Account setting issue.  I think I will create myself another dev acct and go from there.  Thanks for your support and let me know if you think of any other possibility.

Chris

mangiamangia

Created myself a new developer account. Copied Code and S-Control and created a new Tab to host the S-control, and ... yes, it works now!  So there is something different in my initial developer account... but what?

I have compared both dev accts and nothing stands out as being a problem.  However, I did see a couple minor items that might be a clue;
  1) Old dev acct logo says SalesFore SFA 7 and new dev acct logo says SalesForce SFA 8
  2) New dev acct offers 11.0 or 10.0 versions of Code, but old dev acct only offers 10.0

Is this versioning difference causing my problem?  Is there a setting somewhere to let me upgrade my old dev acct to SalesForce SFA 8?

Chris

cheenathcheenath
What is the WSDL location for your web service?

<soap:address location="..." />

My guess is that you have defined a namesapce for old DE account.



Ron HessRon Hess
versioning may be an issue, all remaining instances will be upgraded friday night.
montblanc2000montblanc2000
I had the same problem and it turned out to be the namespace issue. Salesforce--I realize it was my fault for forgetting it, but you should emphasize its importance in the documentation. I spent an entire day seaching for what I was doing wrong.
 
Paul
AkiTAkiT
Agree that it could be highlighted better. Just struggled with the issue - luckily found another post on the topic.

Those who need help: you need to prefix class with namespace: YourNamespace.YourClass
This was selected as the best answer