I am trying to use Continuation for the first time and am hitting a strange error. Below is a simple page I created with both a Synchronous Callout and a Continuation Callout button. When, in my developer org, I press the "Synchronous Callout" button, I get a response as expected. When I press the "Continuation Callout" button I get an error, "Apex class 'ApexPage.ContinuationController' does not exist". Have you seen this? Do I not understand Continuation?
I have created a remote site setting for the service I am calling out to. I have ensured both my page and controller are on API version 33, which is documented as supporting Continuation. I have tried setting my controller and callback method as global, the error made me think that the callback somehow can't see the class containing the actual callback method. That had no effect.
Debug logs show successful completion and exiting of the method "testContinuationCall" The log contains no errors. There is no second log created for the callback, which I would expect.
Page:
<apex:page controller="ContinuationController" showChat="false" showHeader="false" sidebar="false" id="pg">
<apex:pageMessages id="frmMsgs"/>
<apex:form id="pgFrm" >
<apex:commandButton action="{!testSyncCallout}" value="Synchronous Callout" reRender="frmMsgs"/>
<apex:commandButton action="{!testContinuationCall}" value="Continuation Callout" reRender="frmMsgs"/>
</apex:form>
</apex:page>
Controller:
public with sharing class ContinuationController {
private String returnedContinuationId;
private String baseSericeURL = 'http://www.zillow.com/webservice/GetDeepSearchResults.htm';
public ContinuationController() {}
public void testSyncCallout() {
HttpResponse testResponse = new HttpResponse();
HttpRequest testRequest = new HttpRequest();
HTTP HTTPService = new HTTP();
testRequest.setMethod('GET');
testRequest.setEndpoint(baseSericeURL);
testRequest.setTimeout(60000);
testResponse = HTTPService.send( testRequest );
ApexPages.addMessage( new ApexPages.Message(ApexPages.Severity.INFO, testResponse.getStatusCode() + ': ' + testResponse.getStatus() + ' '+ testResponse.getBody()) );
}
public Object testContinuationCall() {
//Timeout in seconds, 60 is limit
Continuation con = new Continuation(60);
//Set callback method
con.continuationMethod='testContinuationCallback';
//Create callout request
HttpRequest req = new HttpRequest();
req.setMethod('GET');
req.setEndpoint(baseSericeURL);
returnedContinuationId = con.addHttpRequest(req);
return con;
}
public Object testContinuationCallback() {
//Get the response by using the unique label
HttpResponse httpRes = Continuation.getResponse(returnedContinuationId);
ApexPages.addMessage( new ApexPages.Message(ApexPages.Severity.INFO, httpRes.getStatusCode() + ': ' + httpRes.getStatus() + ' '+ httpRes.getBody()) );
//Return null to re-render the original Visualforce page
return null;
}
}
Error: