使用jQuery / PhoneGap的肥皂查询总是在Android上失败 [英] Soap query with jQuery / Phonegap always fail on Android

查看:159
本文介绍了使用jQuery / PhoneGap的肥皂查询总是在Android上失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我公司开发使用jQuery Mobile和放大器的iPhone / Android应用程序; PhoneGap的(现在的科尔多瓦)。这个应用程序使用不同的服务没有问题。其中一个这样的服务是一个SOAP之一,所以我用的是jsSOAPClient(jquery.jqSOAPClient.js)的jQuery,以请求服务。我有一点问题都没有使用iOS设备,但该查询始终在Android上失败。

I developed an iPhone/Android app with jQuery mobile & Phonegap (now Cordova). This app use different services with no problem. One of this services is a Soap one so i use the jsSOAPClient (jquery.jqSOAPClient.js) for jQuery in order to request the service. I have no problem at all from an iOS device but the query always fail on Android.

在jsSOAPClient请求看起来像这样:

In jsSOAPClient the request looks like that :

        function getResponse(xData, status) {
            if(!!callback) {
                SOAPClient.Status = xData.status;
                SOAPClient.ResponseText = xData.responseText;
                SOAPClient.ResponseXML = xData.responseXML;
                callback(xData.responseXML);
            }
        }

        $.ajax({
             type: "POST",
             url: SOAPClient.Proxy,
             dataType: "xml",
             processData: false,
             data: content,
             complete: getResponse,
             beforeSend: function(req) {
                req.setRequestHeader("Method", "POST");
                req.setRequestHeader("Content-Length", SOAPClient.ContentLength);
                req.setRequestHeader("Content-Type", SOAPClient.ContentType + "; charset=\"" + SOAPClient.CharSet + "\"");
                req.setRequestHeader("SOAPServer", SOAPClient.SOAPServer);
                req.setRequestHeader("SOAPAction", soapReq.Action);
             }
        });

在GETRESPONSE,状态值为错误和SOAPClient.Status(等于xData.status)为0。

The "getResponse" "status" value is "error" and the "SOAPClient.Status" (equal to "xData.status") value is "0".

服务器似乎没有收到要求在所有...

The server seems to not receive request at all...

我再说一遍,同样的code具有相同的请求DATAS对iOS的结果。

I repeat that the same code with the same request datas have results on iOS.

感谢您的帮助。

/ 修改 的* / 我试图注释行:

/ EDIT */ I tried to comment the line :

//type: "POST",

似乎工作,我的意思是我有一个200状态code在这种情况下,即使我有一个解析错误,由于意外的响应格式。

it seems to work, i mean i have a 200 status code in this case even if i have a parse error due to the unexpected response format.

推荐答案

显然没有在安卓2.x的一个错误的地方设置 内容长度标头导致您所描述的问题。看起来像 该错误已被固定在安卓4.0.3。因此,尝试你的code未修改 在4.0.3仿真器,它应该工作再回过头来2.x和 删除内容长度的头,看看它的工作原理也是如此。

Apparently there is a bug in Android 2.x where setting the "Content-length" header causes the problem you describe. It looks like the bug has been fixed in Android 4.0.3. So try your code unmodified in the 4.0.3 emulator and it should work then come back to 2.x and remove the Content-length header to see if it works as well.

这篇关于使用jQuery / PhoneGap的肥皂查询总是在Android上失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆