I am getting an error on WLResourceRequest
's onsuccess callback and the error is as below.
com.sun.jdi.InternalException : Unexpected JDWP Error: 14 Cannot evaluate com.worklight.wlclient.api.WLResponse.toString()
why do we get this error? is there a way to skip this .
Code I used is
it works fine I get the response when I use WLHttpResponseListener instead of WLResponseListener.
wlResponse.getResponseText(); gives empty response.
WLResourceRequest request = new WLResourceRequest("Actual server path here", GET);
request.addHeader(new BasicHeader("IfAnyHeader", "here"));
request.send(new ResponseListener());
private class ResponseListener implements WLResponseListener {
@Override
public void onSuccess(WLResponse wlResponse) {
responseCode = wlResponse.getStatus();
final String result = wlResponse.getResponseText();
}
@Override
public void onFailure(WLFailResponse wlFailResponse) {
responseCode = wlFailResponse.getStatus();
final String result = wlFailResponse.getResponseText();
}
I get the error on onSuccess method... wlResponse.getResponseText(); is always empty.
I finally found a solution for this issue.
request.send( new WLHttpResponseListener() {
@Override
public void onSuccess(HttpResponse httpResponse) {
BufferedReader reader = null;
try {
// responseCode = httpResponse.getStatusLine();
WLResponse wlResponse=new WLResponse(httpResponse);
int responseCode=wlResponse.getStatus();
reader = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent(), "UTF-8"));
// used a function to convert reader to string
final String result = entityToString(reader);
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void onFailure(HttpResponse httpResponse, Exception e) {
BufferedReader reader = null;
try {
responseCode = new WLFailResponse(new WLResponse(httpResponse)).getStatus();
reader = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent(), "UTF-8"));
String result = entityToString(reader);
} catch (IOException eec) {
e.printStackTrace();
}
}
});