我有一个用java编写并使用axis2server公开的web服务。我需要使用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");
});
但我得到未定义的错误。提前谢谢。