我正在尝试在 javascript / Jquery 中调用 asp.net webservice,我尝试了很多示例,但不幸的是没有成功,
这是我目前正在尝试的代码,
login("abc@gmail.com", "123456");
var productServiceUrl = 'http://localhost:50575/Service1.asmx?op=test'; // Preferably write this out from server side
function login(Email, Password) {
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> \
<login xmlns="http://test.com/"> \
<Email>' + Email + '</Email> \
<Password>' + Password + '</Password> \
</login> \
</soap:Body> \
</soap:Envelope>';
$.ajax({
url: productServiceUrl,
type: "GET",
dataType: "xml",
data: soapMessage,
complete: endSaveProduct,
error: function (a, b, c) {
alert(a + "\n" + b + "\n" + c);
},
contentType: "text/xml; charset=\"utf-8\""
});
return false;
}
function endSaveProduct(xmlHttpRequest, status) {
$(xmlHttpRequest.responseXML)
.find('loginResult')
.each(function () {
alert( $(this).find('Message').text());
});
}
请帮帮我,在此先感谢。