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;
}
相關文章
相關標籤/搜索