ajax 异步请求webservice(XML格式)

function callAjaxWebservice(){
				alert("call ajax");
                 try {
                     $.ajax({
                         type: "POST",  //访问WebService使用post方式请求
                         contentType: "text/xml;utf-8",//使用的xml格式的
                         url: "http://192.168.6.176:8899/arch/entry/services/CheckLogin", //调用WebService的地址和方法名称组合
                         data: getPostData(),  //这里是要传递的参数
                         dataType: "xml",  //参数类型为xml
                         success: function (result) {
                             alert("call succ:"+result);
                         },
                         error: function(res,err){
                         	alert("call failed:"+res.responseText);
                         }
                     })
                 }
                 catch (ex) {
                     alert(ex);
                 }
}
function getPostData(){
	var data="<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ser=\"http://service.checklogin.assetpda.business/\">"+
		  "<soapenv:Header/>" +
		  "<soapenv:Body>"  +
		      "<ser:validUser>" +		         		         		         
		         "<arg0>wu</arg0><arg1>1234</arg1>" +
		       "</ser:validUser>" +
		   "</soapenv:Body>" + 
		  "</soapenv:Envelope>";


	return data;
}

 

posted on 2014-03-06 17:11  心笑峰  阅读(4996)  评论(0编辑  收藏  举报

导航