[英]call soap wsdl using jquery
我有一個用java編寫的web服務,並使用axis2server公開。我需要使用jquery來調用服務。我的UI托管在同一台機器上但在不同的端口(8080)。 我嘗試了以下代碼
$('#submit').click(function (event) {
alert("success");
var soapmessage = "<soap:Envelope xmlns:soap='http://www.w3.org/2003/05/soap-envelope' " + " xmlns:iris='http://iris.ramco.com'>";
soapmessage += "<soap:Header/>";
soapmessage += "<soap:Body>";
soapmessage += "<iris:authenticateUser>";
soapmessage += "<inputjson> {username:'admin',password:'admin12*'}</inputjson>";
soapmessage += "</iris:authenticateUser>";
soapmessage += "</soap:Body>";
soapmessage += "</soap:Envelope>";
alert(soapmessage);
$.ajax({
type: 'Post',
url: 'http://localhost:8090/axis2/services/CiRISService',
data: soapmessage,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
alert(data);
},
error: function (data) {
alert("eror" + data.d);
}
});
alert("Form Submitted");
});
但我得到了未定義的錯誤。謝謝你提前。
為什么不使用SOAP客戶端庫? 例如,有一個jQuery插件: http : //archive.plugins.jquery.com/project/jqSOAPClient
請記住,如果沒有專門的庫,您永遠不應該直接調用SOAP方法。 你不會想到太多的陷阱。
您正在使用內容類型"application/json; charset=utf-8"
(和數據類型"json"
)來獲取soap請求。 而是嘗試這些
contentType:“text / xml; charset = utf-8”
dataType:“xml”
編輯:我同意Shedal,但是使用一個庫。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.