当前位置: 代码迷 >> Web Service >> JS调用Webservice,回来XML以表格形式显示
  详细解决方案

JS调用Webservice,回来XML以表格形式显示

热度:237   发布时间:2016-05-02 02:45:49.0
JS调用Webservice,返回XML以表格形式显示
http://localhost:1652/WebServiceJS/FixService.asmx/Query

方法名:Query

WSDL如下:
  <?xml version="1.0" encoding="utf-8" ?> 
- <DataSet xmlns="http://tempuri.org/">
- <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
- <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
- <xs:complexType>
- <xs:choice minOccurs="0" maxOccurs="unbounded">
- <xs:element name="mytable">
- <xs:complexType>
+ <xs:sequence>
  <xs:element name="ID" type="xs:int" minOccurs="0" /> 
  <xs:element name="Name" type="xs:string" minOccurs="0" /> 
  <xs:element name="Age" type="xs:string" minOccurs="0" /> 
  </xs:sequence>
  </xs:complexType>
  </xs:element>
  </xs:choice>
  </xs:complexType>
  </xs:element>
  </xs:schema>
- <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
- <NewDataSet xmlns="">
- <mytable diffgr:id="mytable1" msdata:rowOrder="0">
  <ID>0</ID> 
  <Name>123</Name> 
  <Age>12</Age> 
  </mytable>
- <mytable diffgr:id="mytable2" msdata:rowOrder="1">
  <ID>1</ID> 
  <Name>张三</Name> 
  <Age>11</Age> 
  </mytable>
- <mytable diffgr:id="mytable3" msdata:rowOrder="2">
  <ID>2</ID> 
  <Name>李四</Name> 
  <Age>12</Age> 
  </mytable>
- <mytable diffgr:id="mytable4" msdata:rowOrder="3">
  <ID>3</ID> 
  <Name>王五</Name> 
  <Age>13</Age> 
  </mytable>
- <mytable diffgr:id="mytable5" msdata:rowOrder="4">
  <ID>4</ID> 
  <Name>吴六</Name> 
  <Age>14</Age> 
  </mytable>
- <mytable diffgr:id="mytable6" msdata:rowOrder="5">
  <ID>5</ID> 
  <Name>小五</Name> 
  <Age>15</Age> 
  </mytable>
  </NewDataSet>
  </diffgr:diffgram>
  </DataSet>
-----------------------------------------------
怎么样在JS中调用这个webservice方法,并且以表格的形式显示?

求助~!~!~!~!~
------解决方案--------------------
function load(){
    xmlHttpRequest = new XMLHttpRequest();
    xmlHttpRequest.open('GET', serviceUrl , true);
    xmlHttpRequest.onreadystatechange = GetOrders_OnReadyStateChange;
    xmlHttpRequest.setRequestHeader('Content-Type', 'text/xml');
    xmlHttpRequest.send();

function GetOrders_OnReadyStateChange()
{
    if (xmlHttpRequest.readyState == 4) 
  相关解决方案