35 lines
1.2 KiB
OpenEdge ABL
35 lines
1.2 KiB
OpenEdge ABL
public class LongRunningCallout {
|
|
// Declare requestLabel and result as class variables
|
|
public String requestLabel {get; set;}
|
|
public String result {get; set;}
|
|
|
|
public Object startRequest() {
|
|
// Create continuation with a timeout
|
|
Continuation con = new Continuation(60);
|
|
con.continuationMethod = 'processResponse';
|
|
|
|
// Create callout request
|
|
HttpRequest req = new HttpRequest();
|
|
req.setMethod('GET');
|
|
req.setEndpoint('https://jsonplaceholder.typicode.com/posts');
|
|
|
|
// Add callout request to continuation
|
|
this.requestLabel = con.addHttpRequest(req);
|
|
|
|
// Return the continuation
|
|
return con;
|
|
}
|
|
|
|
// The callback method that processes the callout response
|
|
public Object processResponse() {
|
|
// Get the response by using the request label
|
|
HttpResponse response = Continuation.getResponse(this.requestLabel);
|
|
result = response.getBody();
|
|
System.debug('Response-result:' + result);
|
|
// Process the response
|
|
System.debug('Response: ' + response.getBody());
|
|
|
|
// You can return null or a PageReference here
|
|
return null;
|
|
}
|
|
} |