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
bharath11rbharath11r 

Call Webservices from BatchApex

Hello ,

              I recently started developing in Apex with .net background and I am looking for insight to solve the below problem.

 

I have 30K carriers(Account) objects and need to update them on a nightly basis from a webservice (like insurance etc ).

 

I was able to successfully implement the webservice and update a single account but now I have to do that in a batch

 

Class UpdateService-- Take AccountObject and gets the latest information and does a DML.

 

ClassBatchAccounts--Gets the list of all Accounts and pass each account to above class

 

ClasScheduleBatch--Call above BatchAccounts(every day inthe morning).

 

When i implement this i am getting too many callouts.

 

I need to call webservice for each account so how can i do that in ApexBatch?

 

Any insight would be helpfull...

 

 

ForceMantis (Amit Jain)ForceMantis (Amit Jain)

Limit for toal number of callouts in a request in 10.

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_gov_limits.htm

 

In Batch Apex each batch is treated as fresh request and all governor limits are reset for each batch. You can reduce size of records processed in each batch to 10 to workaround your situaiton.

 

Database.executebatch(new myBatchclass(),10);

juan.cardonajuan.cardona

Works for me, Thanks!

ForceMantis (Amit Jain)ForceMantis (Amit Jain)

Hi

 

Glad to know that it worked for you. As a community best practice it will be good to mark the answer as solution to help others also.