2011-01-28 4 views
1

PhoneGapフレームワークを使用して小さな連絡先ストアアプリケーションを開発しています。連絡先の作成、更新、閲覧、削除の操作を行うWebサービスがあります。連絡先を作成するSOAPリクエストを作成するために、次のコードを使用しています。私たちはjQueryとjquery mobileを使っていますhttp://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.js。次のコードは、iPhoneシミュレータとiPhoneで動作します。しかし、私たちはAndroidとAndroidのエミュレータでも対応していません。私たちはあなたの助けに大いに感謝します。PhoneGap jQueryを使用したAndroid Webサービスの応答が行われない

var settings = {requestType:"soap1.1", 
     error:function(XMLHttpRequest, textStatus, errorThrown){ 
     throw XMLHttpRequest.responseText; 
    }}; 
var oBuffer = new Array(); 
settings.requestType = "soap1.1"; 
settings.methodType = "POST"; 
settings.contentType = "text/xml"; 
settings.url = "http://example.com/checkdatpriceservice.asmx"; 
settings.dataType = "text/xml"; 
settings.nameSpace = "http://tempuri.org/"; 
settings.methodName = "VerifyUser"; 

oBuffer.push('<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'); 
oBuffer.push("<soap:Body>"); 
    oBuffer.push('<VerifyUser xmlns="http://tempuri.org/">'); 
    oBuffer.push('<email_id>[email protected]</email_id>'); 
    oBuffer.push('<password>user123</password>'); 
    oBuffer.push("</VerifyUser>"); 
    oBuffer.push("</soap:Body>"); 
oBuffer.push("</soap:Envelope>"); 
settings.requestData = oBuffer.join(""); 
alert("requestData:" + settings.requestData); 
$.ajax({ 
    type: settings.methodType, 
    cache: false, 
    url: settings.url, 
    data: settings.requestData, 
    contentType: settings.contentType, 
    dataType: settings.dataType, 
    error: function(status){ alert("An error occurred in processing your request");}, 
    success: function(data, testStatus){ 
    alert('data = ' + data); 
    $('#testp').html(data); 
    }, 
    beforeSend: function(XMLHttpRequest){ 
    if (settings.requestType == "soap1.1" || settings.requestType== "soap1.2") 
     XMLHttpRequest.setRequestHeader("SOAPAction",settings.nameSpace + settings.methodName); 
    XMLHttpRequest.setRequestHeader("Content-Length",settings.requestData.length); 
    XMLHttpRequest.setRequestHeader("Connection", "close"); 
    } 
}); 
+0

私はそれがうまくいくように見えます。 'adb logcat'を実行してデバイス/エミュレータのログを調べると、エラーはありますか? 'adb logcat |を実行してみてください。 grep "Web" 'ブラウザ/ PhoneGapに関連する出力のみを取得します。 –

+0

私も同様の問題があります:http://stackoverflow.com/questions/10176985/soap-query-with-jquery-phonegap-always-fail-on-android 解決策はありましたか? – Chaaarly

答えて

0

私も同じ問題を抱えていました。 eclipseでindex.htmlを実行しようとすると、すべて正常に動作します。 しかし、シミュレータで実行しようとすると、応答データはありません。 私は、応答データの長ささえもゼロであることを発見しました。

誰かが解決策やPhoneGapのは、石鹸XML要求を受け取り、XMLで応答を与えるWebサービスを実行する方法の小さな例を投稿することができれば素晴らしいことです。

0

私はlogcatを実行しようとしましたが、Webサービスを実行するボタンがクリックされたときに「Web」という単語が見つかりませんでした。

0

「text/xml」の代わりにsettings.dataType = "xml"を使用してみてください。

「text/xmlで」$アヤックスコールので、インテリジェントな推測では、あなたのiPhoneにしていないあなたのアンドロイドシムで実行している可能性のために有効なのdataTypeではありません。

関連する問題