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

查看:20
本文介绍了使用 jQuery/Phonegap 的 Soap 查询在 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"status"值为error",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...

我再说一遍,同样的代码,同样的请求数据,在 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 状态代码,即使由于意外的响应格式而出现解析错误.

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.

推荐答案

显然在 Android 2.x 中设置了一个错误内容长度"标题会导致您描述的问题.看起来像该错误已在 Android 4.0.3 中修复.所以试试你的代码未经修改在 4.0.3 模拟器中它应该可以工作然后回到 2.x 和删除 Content-length 标头,看看它是否也能正常工作.

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 的 Soap 查询在 Android 上总是失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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