js 调用webservices?怎么实现啊

问题描述:

js 调用webservices?怎么实现啊
webservices 是Java写的。
我有段代码
function RequestWebService() {

var URL = "http://localhost:8080/web_services/services/Login.jws?wsdl/getDomXML";
var data;
data = '<?xml version="1.0" encoding="utf-8"?>';
data = data + '';

data = data + 'soap12:Body';

data = data + '';

data = data + '/soap12:Body';

data = data + '/soap12:Envelope';

//创建异步对象

var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.Open("POST", URL, false);
xmlhttp.SetRequestHeader ("Content-Type","text/xml; charset=utf-8");
//xmlhttp.SetRequestHeader("Content-Type", "application/soap+xml");
//xmlhttp.SetRequestHeader("SOAPAction", "http://server/getDomXML");
xmlhttp.Send(data);
//document.getElementById("data").innerHTML = xmlhttp.responseText;
}
老报:faultString: no SOAPAction header!
如果打开xmlhttp.SetRequestHeader("SOAPAction", "http://server/getDomXML");又调用不到webservices

现在使用ajax技术的话,都是使用jquery,jquery的实现封装了很多实现细节,方便我们使用,而且解决了浏览器问题,所以建议你去看下jquery的ajax这块的功能,使用很简单
[code="js"]
$(function(){
$.getJson(url,{param:"param1"},function(data){//如返回对象有一个username属性
alert(data.username);
});
});
[/code]
以上给你一个简单的例子,其实本质都差不多,你自己去了解下,会更好!