I need to implement a function that calls a web service and return the response.
I tried
public String getFolderJson(String path) {
Stri
Try the same solution offered above except not with an anonymous Callback.
public String getFolderJson(String path) {
RequestBuilder builder = new RequestBuilder(...);
HttpCallback cb=new HttpCallback();
try {
builder.sendRequest(null, cb);
} catch (RequestException e) {
// exception handling
logger.severe(cb.err);
}
return cb.result;
}
class HttpCallback implements RequestCallback{
String result;
String err;
HttpCallback(){}
@Override
public void onResponseReceived(Request request, Response response) {
result=response.getText());
}
@Override
public void onError(Request request, Throwable exception) {
err=exception.getMessage();
}
}