<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    軟件工程實踐者

    統計

    留言簿

    友情鏈結

    閱讀排行榜

    評論排行榜

    JavaScript調用Web service

    要調用的Web服務是求兩個整數和,并返回結果。

    服務的WSDL文件內容如下:
    <?xml version="1.0" encoding="utf-8" ?> 
    <wsdl:definitions
        xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
        xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
        xmlns:s="http://www.w3.org/2001/XMLSchema" 
        xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
        xmlns:tns="http://tempuri.org/"  
        xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" 
        xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" 
        targetNamespace="http://tempuri.org/" 
        xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
      <wsdl:types>
         <s:schema elementFormDefault="qualified"  
            targetNamespace="http://tempuri.org/">
            <s:element name="AddTwoIntegers">
                <s:complexType>
                   <s:sequence>  
                      <s:elementminOccurs="1" maxOccurs="1" name="IntegerOne" type="s:int" />    
                      <s:elementminOccurs="1" maxOccurs="1" name="IntegerTwo" type="s:int" />   
                   </s:sequence>
                </s:complexType>
            </s:element>
            <s:element name="AddTwoIntegersResponse">
                <s:complexType>
                    <s:sequence> 
                       <s:elementminOccurs="1" maxOccurs="1" name="AddTwoIntegersResult" type="s:int" />    
                    </s:sequence>
                </s:complexType>
            </s:element>
         </s:schema>
      </wsdl:types>
      <wsdl:message name="AddTwoIntegersSoapIn"> 
          <wsdl:part name="parameters" element="tns:AddTwoIntegers" />
      </wsdl:message>
      <wsdl:message name="AddTwoIntegersSoapOut">  
          <wsdl:part name="parameters" element="tns:AddTwoIntegersResponse" />   
       </wsdl:message>
       <wsdl:portType name="SimpleServiceSoap">
           <wsdl:operation name="AddTwoIntegers">
              <wsdl:input message="tns:AddTwoIntegersSoapIn" />
              <wsdl:output message="tns:AddTwoIntegersSoapOut" />    
           </wsdl:operation> 
       </wsdl:portType>
    
       <wsdl:binding name="SimpleServiceSoap" type="tns:SimpleServiceSoap"> 
           <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> 
           <wsdl:operation name="AddTwoIntegers">   
               <soap:operation soapAction="http://tempuri.org/AddTwoIntegers" style="document" /> 
               <wsdl:input>  
                   <soap:body use="literal" />    
               </wsdl:input>
               <wsdl:output>  
                   <soap:body use="literal" />    
               </wsdl:output>
           </wsdl:operation>
      </wsdl:binding>
      <wsdl:service name="SimpleService"> 
          <documentation xmlns="http://schemas.xmlsoap.org/wsdl/" /> 
          <wsdl:port name="SimpleServiceSoap" binding="tns:SimpleServiceSoap">  
              <soap:address location="http://localhost/Develop.NET/Home.Develop.WebServices/SimpleService.asmx"/>  
          </wsdl:port>  
      </wsdl:service> 
    </wsdl:definitions>
    


    javaScript代碼中利用了MS的HTTP代理對象XMLHTTP,在Mozilla's Web brower中相應的組件是XMLHttpRequest,他們都提供了類似的方法來完成soap請求。下面的代碼用的是IE中的XMLHTTP對象。代碼假定調用過程中沒有Fault。
    function fncAddTwoIntegers(a, b)
    {    
        var oXmlHttp = new ActiveXObject("MSXML2.XMLHTTP");      
        oXmlHttp.open("POST", "http://localhost/Develop.NET/Home.Develop.WebServices/SimpleService.asmx'", false);
        oXmlHttp.setRequestHeader("Content-Type", "text/xml");    
        oXmlHttp.setRequestHeader("SOAPAction", "http://tempuri.org/AddTwoIntegers");
    
        oXmlHttp.send("      
    <soap:Envelopexmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>
    <soap:Body> <AddTwoIntegersxmlns='http://tempuri.org/'> <IntegerOne>" + a + "</IntegerOne> <IntegerTwo>" + b + "</IntegerTwo> </AddTwoIntegers>
    </soap:Body> </soap:Envelope>"); return oXmlHttp.responseXML.selectSingleNode("http://AddTwoIntegersResult").text; }


    原文英文出自:http://builder.com.com/5100-6371_14-5887775.html?tag=nl.e601

    posted on 2006-01-05 20:01 軟件工程實踐者 閱讀(1216) 評論(3)  編輯  收藏 所屬分類: Web service

    評論

    # re: JavaScript調用Web service 2010-12-06 17:53 你爹

    傻逼  回復  更多評論   

    # re: JavaScript調用Web service 2010-12-06 17:54 你爹

    傻逼,不好使  回復  更多評論   

    # re: JavaScript調用Web service 2010-12-06 17:54 你爹

    傻逼  回復  更多評論   


    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 亚洲成a人片77777kkkk| 免费看AV毛片一区二区三区| 久久久无码精品亚洲日韩软件| 亚洲av无码成人精品国产| 24小时日本在线www免费的| 四虎必出精品亚洲高清| 热久久精品免费视频| 日日摸日日碰夜夜爽亚洲| 亚洲国产精品第一区二区三区| 无套内谢孕妇毛片免费看看| 久久亚洲中文字幕精品一区| A国产一区二区免费入口| 久久精品国产精品亚洲蜜月| 99久久久国产精品免费牛牛| 亚洲成aⅴ人片在线观| 永久免费bbbbbb视频| 免费人成在线观看播放a| a级亚洲片精品久久久久久久 | 久久天天躁狠狠躁夜夜免费观看| 亚洲一级大黄大色毛片| 国内一级一级毛片a免费| 色屁屁www影院免费观看视频| 在线精品亚洲一区二区三区| 性色午夜视频免费男人的天堂| 亚洲av成人综合网| 日韩精品电影一区亚洲| 日本免费中文字幕| 亚洲午夜理论片在线观看| 亚洲成A人片在线观看无码3D| 日本视频在线观看永久免费| 亚洲综合精品第一页| 亚洲无码在线播放| 91免费精品国自产拍在线不卡| 一道本不卡免费视频| 亚洲精品中文字幕乱码| 亚洲av再在线观看| 1024免费福利永久观看网站| 国产亚洲福利精品一区二区| 亚洲午夜精品久久久久久人妖| 国产又粗又长又硬免费视频 | 国产精品无码亚洲精品2021|