一個JavaScript庫,這裏是一個AJAX調用JavaScript的
$.ajax({
url: "Login.aspx/Logout",
type: "POST",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (o) {
window.location.href = "Login.aspx";
},
error: function (o) {
logoutSession();
}
});
任何aspx頁面上的服務器端方法。
[WebMethod]
public static string Logout()
{
HttpContext.Current.Session["User"] = null;
return "Success";
}
當調用一個WSDL服務
$.ajax({
url: "Service.svc/Customers",
type: "POST",
dataType: "xml",
data: soapMessage,
processData: false,
contentType: "text/xml; charset=\"utf-8\"",
success: function (xml) { alert(xml); },
error: function (jqXHR, textStatus, errorThrown) { alert(jqXHR.response + textStatus + errorThrown); }
});
的soapMessage
變量包含的代碼看起來是這樣的:
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> \
<SaveProduct xmlns="http://sh.inobido.com/"> \
<productID>' + productID + '</productID> \
<productName>' + productName + '</productName> \
<manufactureDate>' + manufactureDate + '</manufactureDate> \
</SaveProduct> \
</soap:Body> \
</soap:Envelope>';
源http://openlandscape.net/2009/09/25/call-soap-xm-web-services-with-jquery-ajax/
上面的源代碼給你一步如何分步說明,如何來源不起作用,谷歌「如何從ajax做肥皂調用」,會有多個可用的鏈接到這個確切的查詢
也使用'SoapUI'來獲得正確的XML正文發送到服務器,'SoapUI'是一個測試webservices和其他肥皂相關的東西的偉大工具 – Pierre 2014-10-10 15:40:12