私はphonegapアプリに取り組んでいます。.netWebサービスを介してユーザーを検証する必要があります。私はajaxを使用して、javascriptを介して検証および解析していますが、常にゼロを返すため、readystateでスタックしています。ネットで見つけた利用可能なソリューションから多くのことを試しましたが、うまくいきません。
これが私のJavascriptです:
username = 'ksl';
password = 'ksl';
var soapMessage =
'<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/"> \
<soap:Body> \
<CheckLogin xmlns="http://tempuri.org/"> \
<UserName>' + username + '</UserName> \
<Password>' + password + '</Password> \
</CheckLogin> \
</soap:Body> \
</soap:Envelope>';
$.ajax({
url: validationURL,
type: "POST",
dataType: "xml",
data: soapMessage,
success: validate,
contentType: "text/xml; charset=\"utf-8\"",
error: function(xhr,status,error)
{
alert("state is:" + xhr.readyState);
}
});
return false;
これが私のWebサービスの応答です。
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<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/">
<soap:Body>
<CheckLoginResponse xmlns="http://tempuri.org/">
<CheckLoginResult>string</CheckLoginResult>
</CheckLoginResponse>
</soap:Body>
</soap:Envelope>
どんな応答も役に立ちます