+ Start a Discussion
Matan AlonMatan Alon 

Calling a webservice method from apex test class

I have a simple webservice method that updates Account Status from a custom Button in the Opportunity page:

Global class Backoffice {
    WebService static Integer  GenerateBackofficeTask(id  opId) {  
        Opportunity op = [SELECT AccountId from Opportunity WHERE Id =: opId];
                Account ac = [SELECT Id from Account WHERE Id =: op.AccountId];
                ac.Type = 'Customer';
                update ac;

    return 1;

Here the Test class i wrote:

public  class BackOfficeTest {
    static testMethod void TestMyContractWebService() {

   Integer x = 0;  
    Account ac = new Account(Name='testAccount1');
    insert ac ;

    Opportunity op = new Opportunity(Name='testOpportunity1',AccountId=ac.Id,CloseDate =date.parse('12/12/2014'),StageName='Evaluation');
    insert op ;

      x= Backoffice.GenerateBackofficeTask(op.Id); 

I don't know why I'm getting the following error:
Method does not exist or incorrect signature: Backoffice.GenerateBackofficeTask(Id)

Please help me this that - I tried to find the reason with no success

Thanks in advance,
Nilesh Jagtap (NJ)Nilesh Jagtap (NJ)
Hi Matan,

Please refer https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_callouts_wsdl2apex_testing.htm to write test class for webservice.