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
Bernice BotesBernice Botes 

Schedule Batch SOAP call

Hi fellow Trailblazers,  

I'm a novice salesforce developer and wasn't sure if it was even possible to schedule a batch SOAP call. I discovere another thread where someone needed help with the test case of his classes, but didn't explain his approach to the actual implementation. I have implemented my four classes and when I make the call, it seems to schedule it but I don't think that it is actually every executing the code. And in my logs I just get a Problem: This schedulable class has jobs pending or in progress. 
I have an apex class in which I do my SOAP Api callout. Then I have a class in which I do a batch processing. And a schedule class in which I schedule the actual callout. 
The scheduler calls the batch who in return calls the batch who then calls the web service class. 
See code below.
If anyone could just be so kind as too point out any obviouse salesforce rooky mistakes I might be making it would be much appreciated.

//SOAP apex class
 
global with sharing class FmeSOAPCallout{
    global static ElephantService.Service1Soap service = newElephantService.Service1Soap();
     
    webservice static String getObject(String CompanyID, String lmTime, Stringtz){
        String webResult = service.SkyQMobileUnits(CompanyID, lmTime, tz);
        return webResult;
    }
     
}
global class FmeBatchSOAP implements Database.Batchable<sObject>,
Database.AllowsCallouts{
    
    global Integer recordsProcessed = 0;
    
    global FmeBatchSOAP(){}
    
    global Database.QueryLocator start(Database.BatchableContext info){
        return Database.getQueryLocator('SELECT Id, Name, TrackerObject_Timestamp__c '+
                                       'FROM TrackerObject__c');
    }


   global void execute(Database.BatchableContext bc, List<sObject> scope){
       try{
           String results = FmeSOAPCallout.getObject('1091', '0', '120');
           FmeProcessSOAPCall.processSOAPCallout(results);            
       }catch(Exception ex){
           System.debug('FmeBatchSOAP' + ex.getLineNumber() + ex.getMessage()+ ex.getStackTraceString());
           System.abortJob(bc.getJobId());
       }
   }

   global void finish(Database.BatchableContext bc){
       System.debug(recordsProcessed + 'records processed');
       AsyncApexJob job = [SELECT Id, Status, NumberOfErrors, 
                           JobItemsProcessed, 
                          TotalJobItems
                          FROM AsyncApexJob
                          Where Id = :bc.getJobId()];
	System.debug(job);
   }
}
 
global class FmeScheduleSOAP implements Schedulable {

    global void execute(SchedulableContext SC){
		FmeBatchSOAP batch = new FmeBatchSOAP();
		Database.executeBatch(batch);
    }

}