码迷,mamicode.com
首页 > Web开发 > 详细

Js 调用 WebService 实例

时间:2014-07-02 19:58:07      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   java   color   os   

 

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 实例,布布扣,bubuko.com

Js 调用 WebService 实例

标签:style   blog   http   java   color   os   

原文地址:http://www.cnblogs.com/fanlu/p/3819579.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!