Js 调用 WebService 实例

 

Html页面代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Js调用WebService</title>
    <script type="text/javascript">
        function RequestWebService() {
            //这是我们在第一步中创建的Web服务的地址
            var URL = "http://192.168.210.51:8012/Service.asmx";
            var fun = "getAllData";
            
            //在这处我们拼接
            var data;
            data = <?xml version="1.0" encoding="utf-8"?>;
            data = data + <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">;
            data = data + <soap12:Body>;
            data = data + < + fun +  xmlns="http://tempuri.org/" >;
            data = data + <view>V_Gis_Mid_WasteWaterYearData</view>; 
            data = data + <condition>EnterpriseCode = 520100000238</condition>; 
            data = data + </ + fun + >; 
            data = data + </soap12:Body>;
            data = data + </soap12:Envelope>;
            
            //创建异步对象
            var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            xmlhttp.Open("POST", URL, false);
            xmlhttp.SetRequestHeader("Content-Type", "application/soap+xml");
            xmlhttp.Send(data);

            document.getElementById("data").innerHTML = xmlhttp.responseText;
        }      
        
    </script>
</head>
<body>
    <div>
        <input id="One" type="button" value="JsCallWebService" onclick="RequestWebService()" />
    </div>
    <div id="data">
    </div>
</body>
</html>

 

Js 调用 WebService 实例,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。