You need to sign in to do that
Don't have an account?
Lavanya macha
How to Make Multiple asynchronous SOAP Callouts using Continuation API class in one single transaction?
I am doing 2 webservice callouts from VF page contorller method which i am calling from action attribute of <apex:page> tag(onloading of page) and now i am trying to convert those two callouts into asynchronous callouts using continuation API class as stated in below link. Those two callouts need to happen in one single transaction.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_continuation_overview.htm
But i am getting below errors.
Error-1: line -1, column -1: Continuation is not serializable.
Error-2:
An internal server error has occurred
An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience.
Thank you again for your patience and assistance. And thanks for using salesforce.com!
Error ID: 1529128587-55318 (-735899706)
So please help me?
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_continuation_overview.htm
But i am getting below errors.
Error-1: line -1, column -1: Continuation is not serializable.
Error-2:
An internal server error has occurred
An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience.
Thank you again for your patience and assistance. And thanks for using salesforce.com!
Error ID: 1529128587-55318 (-735899706)
So please help me?
You can make maximum 3 callouts in single execution context. Here is sample code : https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_continuation_multiple_callouts.htm. (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_continuation_multiple_callouts.htm)
here is an example of how to execute 3 asynchronous calls::
public Continuation doCal() {
Continuation cont = new Continuation(120);
cont.continuationMethod = 'processResponse';
AsyncSapProductPrices.AsyncY_SF_GETPRICES service1 = new AsyncSapProductPrices.AsyncY_SF_GETPRICES();
pricesResponseFuture1 = service1.beginYSfGetprices(cont, acc.SAP_ID__c, priceDate,
new SapProductPrices.YsfTtProductIn(icw1.itemChunk), selectedSellingOrganisation);
AsyncSapProductPrices.AsyncY_SF_GETPRICES service2 = new AsyncSapProductPrices.AsyncY_SF_GETPRICES();
pricesResponseFuture2 = service2.beginYSfGetprices(cont, acc.SAP_ID__c, priceDate,
new SapProductPrices.YsfTtProductIn(icw2.itemChunk), selectedSellingOrganisation);
AsyncSapProductPrices.AsyncY_SF_GETPRICES service3 = new AsyncSapProductPrices.AsyncY_SF_GETPRICES();
pricesResponseFuture3 = service3.beginYSfGetprices(cont, acc.SAP_ID__c, priceDate,
new SapProductPrices.YsfTtProductIn(icw3.itemChunk), selectedSellingOrganisation);
return cont;
}
public Object processResponse() {
SapProductPrices.YSfGetpricesResponse_element result1;
SapProductPrices.YSfGetpricesResponse_element result2;
SapProductPrices.YSfGetpricesResponse_element result3;
try {
result1 = pricesResponseFuture1.getValue();
result2 = pricesResponseFuture2.getValue();
result3 = pricesResponseFuture3.getValue();
} catch (Exception e) {
system.debug(e);
setErrorMessage(e.getMessage() + ' ' + e.getStackTraceString());
}
return null;
}