+ Start a Discussion
Michael Hedrick 2Michael Hedrick 2 

Faultcode on button calling webservice

I have a custom button calling a webservice but when slected I get this error:
{faultcode: 'soapenv:client', faultString: ' No Operation available for request {http://soap.sforce.com/schemas/package/CallTrexWebServiceInsideSales}TrexWebServiceInsideSales,please check the WSDL for the Service.' ,}
Not sure if its the button or the Class:
Button:
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}

{
 var retStr; 
 retStr = sforce.apex.execute("CallTrexWebServiceInsideSales", "TrexWebServiceInsideSales", {id:'{!Lead.Id}'}); 
}

Class
Global class CallTrexWebServiceInsideSales{
    
    public static Lead leads {get;set;}
    public static String myresponse{get;set;}

    public static string TrexWebServiceInsideSales (String id) {
    
        TrexWebServiceInsideSalesAsync(id);
        return myresponse;        
    }


    @future(Callout=true)
    webservice static void TrexWebServiceInsideSalesAsync(String id) {
    
        leads = [SELECT Email, FirstName , LastName , city  FROM Lead WHERE id =:id];
        
        if(String.isEmpty(leads.email)) {
            myresponse = 'This lead is either missing an email address or the Account Type field is NULL.' ; 
        }
        else
        {
            HttpRequest req = new HttpRequest();
            Http http = new Http();
            req.setMethod('GET');
            
            String ActivityType = 'Sales';
            string Subject = 'Trexpro and Dealer Locations sent to Consumer ';
                  
            String url = 'https://abc/def.asmx' + leads + ActivityType +Subject;
            req.setEndpoint(url);
            
            HTTPResponse resp = http.send(req);
            myresponse = resp.getBody();
         }
    }
}

It was not throwing an error earlier so I am assuming it is due to the Class changes made.  Any suggestions is appreciated.
M


 
MandyKoolMandyKool
The reason its giving you an error message is because your added "webservice" keyword to wrong method.
Add "webservice" to correct method as below and it should work.
webservice static string TrexWebServiceInsideSales (String id) {
    
        TrexWebServiceInsideSalesAsync(id);
        return myresponse;        
    }

 
Michael Hedrick 2Michael Hedrick 2
Thanks MandyKool.  So should the Class look like this:
webservice static string TrexWebServiceInsideSales (String id) {
    
        TrexWebServiceInsideSalesAsync(id);
        return myresponse;        
    }


    @future(Callout=true)
     static void TrexWebServiceInsideSalesAsync(String id)    {

If I remove 
static void TrexWebServiceInsideSalesAsync(String id)

I would receive an error.
MandyKoolMandyKool
Can you please paste your error.
MandyKoolMandyKool
Global class CallTrexWebServiceInsideSales{
    
    public static Lead leads {get;set;}
    public static String myresponse{get;set;}

    webservice static string TrexWebServiceInsideSales (String id) {
    
        TrexWebServiceInsideSalesAsync(id);
        return myresponse;        
    }


    @future(Callout=true)
    webservice static void TrexWebServiceInsideSalesAsync(String id) {
    
        leads = [SELECT Email, FirstName , LastName , city  FROM Lead WHERE id =:id];
        
        if(String.isEmpty(leads.email)) {
            myresponse = 'This lead is either missing an email address or the Account Type field is NULL.' ; 
        }
        else
        {
            HttpRequest req = new HttpRequest();
            Http http = new Http();
            req.setMethod('GET');
            
            String ActivityType = 'Sales';
            string Subject = 'Trexpro and Dealer Locations sent to Consumer ';
                  
            String url = 'https://abc/def.asmx' + leads + ActivityType +Subject;
            req.setEndpoint(url);
            
            HTTPResponse resp = http.send(req);
            myresponse = resp.getBody();
         }
    }
}

Above is the code that I tried.