Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ibm mobilefirst WLResourceRequestOnSuccess抛出错误_Ibm Mobilefirst_Mobilefirst Server - Fatal编程技术网

Ibm mobilefirst WLResourceRequestOnSuccess抛出错误

Ibm mobilefirst WLResourceRequestOnSuccess抛出错误,ibm-mobilefirst,mobilefirst-server,Ibm Mobilefirst,Mobilefirst Server,我在WLResourceRequest的onsuccess回调上收到一个错误,错误如下 com.sun.jdi.InternalException:意外的JDWP错误:14无法计算com.worklight.wlclient.api.WLResponse.toString() 为什么会出现这种错误?有没有办法跳过这个 我使用的代码是 它工作得很好,当我使用 WLHttpResponseListener而不是WLResponseListener wlResponse.getResponseText

我在
WLResourceRequest
的onsuccess回调上收到一个错误,错误如下

com.sun.jdi.InternalException:意外的JDWP错误:14无法计算com.worklight.wlclient.api.WLResponse.toString()

为什么会出现这种错误?有没有办法跳过这个

我使用的代码是

它工作得很好,当我使用 WLHttpResponseListener而不是WLResponseListener

wlResponse.getResponseText();给出空洞的回答

 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();
}

我在onSuccess方法上得到错误。。。wlResponse.getResponseText();始终为空。

WLResponseListener支持WLClient.InvokeProcess

WLHTTPResponseListener支持发送WLResourceRequests


因为您使用的是WLResourceRequest(最佳实践),所以这是预期的行为。

我终于找到了解决此问题的方法

     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();
                        }

                    }
                });

为什么不先提供你已经实现的代码呢?我已经编辑了这个问题,请回答…如果你能够给出否定反馈,你也应该能够给出解决方案。你认为我只是坐在椅子上等你回答吗?您将等待,直到有可能提供答案。这是一个社区。如果你不想在社区中等待,那就打开一张支持票吧。你得到了-1分,因为你写了一个糟糕的问题,没有任何可以帮助调试它的东西。现在,您改进了它,您收到了+1。如果我使用WLHTTPResponseListener,我有一个问题:如何获取状态代码。。因为WLHTTPResponseListener具有HTTPResponse和HTTPResponse。getStatusline()。getStatusCode()不工作。从文档中只返回原始http响应。您必须解析它<代码>成功响应是从服务器收到的任何包含2xx范围内状态的响应。注意:与WLResponseListener.onSuccess(com.worklight.wlclient.api.WLResponse)方法不同,此方法提供原始HTTP响应。MobileFirst平台不会以任何方式尝试读取或处理此响应的内容。