Jquery 如何使用javascript使用axis web服务?
我不熟悉安讯士。我想使用jquery使用axis webserive。我设置了一个简单的axis webservice add方法,并使用以下代码向其发送soap消息:Jquery 如何使用javascript使用axis web服务?,jquery,web-services,Jquery,Web Services,我不熟悉安讯士。我想使用jquery使用axis webserive。我设置了一个简单的axis webservice add方法,并使用以下代码向其发送soap消息: var xmlMsg = "<soapenv:Envelope xmlns:q0=\"http://add.example.ws\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2
var xmlMsg = "<soapenv:Envelope xmlns:q0=\"http://add.example.ws\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><soapenv:Body><q0:add><q0:a1>3.5</q0:a1><q0:a2>5.8</q0:a2></q0:add></soapenv:Body></soapenv:Envelope>"
//var xmlMsg = "<?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><ns1:add xmlns:ns1=\"urn:xmethods-add\"><a1>2.3</a1><a2>4.5</a2></ns1:add></soap:Body></soap:Envelope>";
alert(xmlMsg);
$.ajax({
type: "POST",
contentType:"text/xml; charset=\"utf-8\"",
url:"http://localhost:8080/webServiceProj/services/AddService", //http://localhost:8080/webServiceProj/services/AddService //http://127.0.0.1:8080/soap-proxy/soap/add/1.1
data:xmlMsg,
dataType:'xml',
success: function(xml) {
if($.browser.msie){
$("#result").append(xml.getElementsByTagName("ns1:out")[0].childNodes[0].nodeValue+"<br/>");
}
else{
$(xml).find("out").each(function(){
$("#result").append($(this).text()+"<br/>");
})
}
},
error: function(x, e) {
alert('error:'+x.responseText);
},
complete: function(x) {
alert('complete:'+x.responseText);
}
});
但我从回答中得到的是,说SOAPAction有错是错误的。谁能告诉我一些方向吗?提前感谢。此用于jQuery的SOAP插件可能有助于:
您必须将SOAPAction头添加到请求中,就像您已经添加的类型和内容类型一样。Axis web服务?你是说Ajax web服务吗?我创建的web服务使用axis框架。事实上,它是由eclipse自动生成的。我想从一个网页以ajax的方式使用这个web服务。有很多使用.net的例子。