WebService调用天气接口例子

转自:http://blog.csdn.net/nk_tf/article/details/50708159

一、生成client端的java class文件

天气预报XML:http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl

调用这个URL的接口:http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx

cmd执行

[plain]  view plain  copy
  1. wsimport -s D:\MyEclipse\Workspaces\WebServiceDemo\src -p com.neil.WebService.Client -keephttp://webservice.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl  

其中:

-s参数值的是生成的文件放哪里,指定放在你的项目的src文件夹下。

-p参数是java 的包名

-keep参数是返回xml文件的url的地址

执行cmd命令时可能会出现:[ERROR] undefined element declaration 's:schema'的错误,这是因为该wsdl里面包含 ref = "s:schema" 这样的引用。而jaxb是不支持的。所以手动将该wsdl下载(也就是网页另存为WeatherWS.xml)下来做下修改,修改方法为:

将所有的<s:element ref="s:schema"/> 改成 <s:any minOccurs="2" maxOccurs="2"/>,并且删除<s:any/>。(第二种方法:直接删除

<s:element ref="s:schema"/>也可以,两种方式选其一

然后通过wsimport生成java文件。这次的cmd命令与之前的不同,如下:

wsimport -s D:\MyEclipse\Workspaces\WebServiceDemo\src -p com.neil.WebService.Client -keepWeatherWS.xml
WeatherWS.xml为http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl页面另存为的xml并修改后的文件,执行命令时,该文件需在命令行的路径下,即命令可以找到该文件。

这时生成的文件为



project刷新

二、写java Code测试方法  

[html]  view plain  copy
    1. public static void main(String[] args) {
      WeatherWebService factory = new WeatherWebService();
      WeatherWebServiceSoap swSoap = factory.getWeatherWebServiceSoap();
      ArrayOfString weather = swSoap.getWeatherbyCityName("张家口");
      List<String> weatList = weather.getString();
      for(String temp:weatList){  
                      System.out.println(temp);  
              }
      }
    效果:



三、总结:

1.可以把URL返回的xml另存为xml文件进行修改。

2.可以从xml文件查看service class是哪个,一般是<wsdl:service name="XXX">,XXX即为service class。Soap class一般为调用指定方法的class,一般通过service class的提供get方法获取,如本例的,weatherWS.getWeatherWSSoap()  

PS:更准确的使用可以参考URL的接口方法文档说明。

3.贴上我的xml文件供参考,可以看看理解第2点的总结。

[html]  view plain  copy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://WebXml.com.cn/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://WebXml.com.cn/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">  
  3.   <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"><a href="http://www.webxml.com.cn/" target="_blank">WebXml.com.cn</a> <strong>2400多个城市天气预报Web服务</strong>,包含2300个以上中国城市和100个以上国外城市天气预报数据。数据每2.5小时左右自动更新一次,准确可靠。<br />使用本站 WEB 服务请注明或链接本站:<a href="http://www.webxml.com.cn/" target="_blank">http://www.webxml.com.cn/</a> 感谢大家的支持!<br /><br /><img alt="PDF" title="PDF file" src="http://www.webxml.com.cn/images/icon/pdf.gif" style="vertical-align: middle;" /> <a href="http://www.webxml.com.cn/files/WeatherWsHelp.pdf" target="_blank">接口帮助文档</a> &nbsp;&nbsp;&nbsp; <img alt="ZIP" title="ZIP file" src="http://www.webxml.com.cn/images/icon/zip.gif" style="vertical-align: middle;" /> <a href="http://www.webxml.com.cn/files/about_city.zip">部分城市介绍和气候背景</a> &nbsp;&nbsp;&nbsp; <img alt="ZIP" title="ZIP file" src="http://www.webxml.com.cn/images/icon/zip.gif" style="vertical-align: middle;" /> <a href="http://www.webxml.com.cn/files/city_photo.zip">部分城市图片</a> &nbsp;&nbsp;&nbsp; <img alt="HTML" title="HTML file" src="http://www.webxml.com.cn/images/icon/html.gif" style="vertical-align: middle;" /> <a href="http://www.webxml.com.cn/zh_cn/weather_icon.aspx" target="_blank">天气现象和图例</a><br />&nbsp;</wsdl:documentation>  
  4.   <wsdl:types>  
  5.     <s:schema elementFormDefault="qualified" targetNamespace="http://WebXml.com.cn/">  
  6.       <s:element name="getRegionDataset">  
  7.         <s:complexType />  
  8.       </s:element>  
  9.       <s:element name="getRegionDatasetResponse">  
  10.         <s:complexType>  
  11.           <s:sequence>  
  12.             <s:element minOccurs="0" maxOccurs="1" name="getRegionDatasetResult">  
  13.               <s:complexType>  
  14.                 <s:sequence>  
  15.                   <s:any minOccurs="2" maxOccurs="2" />  
  16.                     
  17.                 </s:sequence>  
  18.               </s:complexType>  
  19.             </s:element>  
  20.           </s:sequence>  
  21.         </s:complexType>  
  22.       </s:element>  
  23.       <s:element name="getRegionProvince">  
  24.         <s:complexType />  
  25.       </s:element>  
  26.       <s:element name="getRegionProvinceResponse">  
  27.         <s:complexType>  
  28.           <s:sequence>  
  29.             <s:element minOccurs="0" maxOccurs="1" name="getRegionProvinceResult" type="tns:ArrayOfString" />  
  30.           </s:sequence>  
  31.         </s:complexType>  
  32.       </s:element>  
  33.       <s:complexType name="ArrayOfString">  
  34.         <s:sequence>  
  35.           <s:element minOccurs="0" maxOccurs="unbounded" name="string" nillable="true" type="s:string" />  
  36.         </s:sequence>  
  37.       </s:complexType>  
  38.       <s:element name="getRegionCountry">  
  39.         <s:complexType />  
  40.       </s:element>  
  41.       <s:element name="getRegionCountryResponse">  
  42.         <s:complexType>  
  43.           <s:sequence>  
  44.             <s:element minOccurs="0" maxOccurs="1" name="getRegionCountryResult" type="tns:ArrayOfString" />  
  45.           </s:sequence>  
  46.         </s:complexType>  
  47.       </s:element>  
  48.       <s:element name="getSupportCityDataset">  
  49.         <s:complexType>  
  50.           <s:sequence>  
  51.             <s:element minOccurs="0" maxOccurs="1" name="theRegionCode" type="s:string" />  
  52.           </s:sequence>  
  53.         </s:complexType>  
  54.       </s:element>  
  55.       <s:element name="getSupportCityDatasetResponse">  
  56.         <s:complexType>  
  57.           <s:sequence>  
  58.             <s:element minOccurs="0" maxOccurs="1" name="getSupportCityDatasetResult">  
  59.               <s:complexType>  
  60.                 <s:sequence>  
  61.                   <s:any minOccurs="2" maxOccurs="2" />  
  62.                     
  63.                 </s:sequence>  
  64.               </s:complexType>  
  65.             </s:element>  
  66.           </s:sequence>  
  67.         </s:complexType>  
  68.       </s:element>  
  69.       <s:element name="getSupportCityString">  
  70.         <s:complexType>  
  71.           <s:sequence>  
  72.             <s:element minOccurs="0" maxOccurs="1" name="theRegionCode" type="s:string" />  
  73.           </s:sequence>  
  74.         </s:complexType>  
  75.       </s:element>  
  76.       <s:element name="getSupportCityStringResponse">  
  77.         <s:complexType>  
  78.           <s:sequence>  
  79.             <s:element minOccurs="0" maxOccurs="1" name="getSupportCityStringResult" type="tns:ArrayOfString" />  
  80.           </s:sequence>  
  81.         </s:complexType>  
  82.       </s:element>  
  83.       <s:element name="getWeather">  
  84.         <s:complexType>  
  85.           <s:sequence>  
  86.             <s:element minOccurs="0" maxOccurs="1" name="theCityCode" type="s:string" />  
  87.             <s:element minOccurs="0" maxOccurs="1" name="theUserID" type="s:string" />  
  88.           </s:sequence>  
  89.         </s:complexType>  
  90.       </s:element>  
  91.       <s:element name="getWeatherResponse">  
  92.         <s:complexType>  
  93.           <s:sequence>  
  94.             <s:element minOccurs="0" maxOccurs="1" name="getWeatherResult" type="tns:ArrayOfString" />  
  95.           </s:sequence>  
  96.         </s:complexType>  
  97.       </s:element>  
  98.       <s:element name="DataSet" nillable="true">  
  99.         <s:complexType>  
  100.           <s:sequence>  
  101.             <s:any minOccurs="2" maxOccurs="2" />  
  102.               
  103.           </s:sequence>  
  104.         </s:complexType>  
  105.       </s:element>  
  106.       <s:element name="ArrayOfString" nillable="true" type="tns:ArrayOfString" />  
  107.     </s:schema>  
  108.   </wsdl:types>  
  109.   <wsdl:message name="getRegionDatasetSoapIn">  
  110.     <wsdl:part name="parameters" element="tns:getRegionDataset" />  
  111.   </wsdl:message>  
  112.   <wsdl:message name="getRegionDatasetSoapOut">  
  113.     <wsdl:part name="parameters" element="tns:getRegionDatasetResponse" />  
  114.   </wsdl:message>  
  115.   <wsdl:message name="getRegionProvinceSoapIn">  
  116.     <wsdl:part name="parameters" element="tns:getRegionProvince" />  
  117.   </wsdl:message>  
  118.   <wsdl:message name="getRegionProvinceSoapOut">  
  119.     <wsdl:part name="parameters" element="tns:getRegionProvinceResponse" />  
  120.   </wsdl:message>  
  121.   <wsdl:message name="getRegionCountrySoapIn">  
  122.     <wsdl:part name="parameters" element="tns:getRegionCountry" />  
  123.   </wsdl:message>  
  124.   <wsdl:message name="getRegionCountrySoapOut">  
  125.     <wsdl:part name="parameters" element="tns:getRegionCountryResponse" />  
  126.   </wsdl:message>  
  127.   <wsdl:message name="getSupportCityDatasetSoapIn">  
  128.     <wsdl:part name="parameters" element="tns:getSupportCityDataset" />  
  129.   </wsdl:message>  
  130.   <wsdl:message name="getSupportCityDatasetSoapOut">  
  131.     <wsdl:part name="parameters" element="tns:getSupportCityDatasetResponse" />  
  132.   </wsdl:message>  
  133.   <wsdl:message name="getSupportCityStringSoapIn">  
  134.     <wsdl:part name="parameters" element="tns:getSupportCityString" />  
  135.   </wsdl:message>  
  136.   <wsdl:message name="getSupportCityStringSoapOut">  
  137.     <wsdl:part name="parameters" element="tns:getSupportCityStringResponse" />  
  138.   </wsdl:message>  
  139.   <wsdl:message name="getWeatherSoapIn">  
  140.     <wsdl:part name="parameters" element="tns:getWeather" />  
  141.   </wsdl:message>  
  142.   <wsdl:message name="getWeatherSoapOut">  
  143.     <wsdl:part name="parameters" element="tns:getWeatherResponse" />  
  144.   </wsdl:message>  
  145.   <wsdl:message name="getRegionDatasetHttpGetIn" />  
  146.   <wsdl:message name="getRegionDatasetHttpGetOut">  
  147.     <wsdl:part name="Body" element="tns:DataSet" />  
  148.   </wsdl:message>  
  149.   <wsdl:message name="getRegionProvinceHttpGetIn" />  
  150.   <wsdl:message name="getRegionProvinceHttpGetOut">  
  151.     <wsdl:part name="Body" element="tns:ArrayOfString" />  
  152.   </wsdl:message>  
  153.   <wsdl:message name="getRegionCountryHttpGetIn" />  
  154.   <wsdl:message name="getRegionCountryHttpGetOut">  
  155.     <wsdl:part name="Body" element="tns:ArrayOfString" />  
  156.   </wsdl:message>  
  157.   <wsdl:message name="getSupportCityDatasetHttpGetIn">  
  158.     <wsdl:part name="theRegionCode" type="s:string" />  
  159.   </wsdl:message>  
  160.   <wsdl:message name="getSupportCityDatasetHttpGetOut">  
  161.     <wsdl:part name="Body" element="tns:DataSet" />  
  162.   </wsdl:message>  
  163.   <wsdl:message name="getSupportCityStringHttpGetIn">  
  164.     <wsdl:part name="theRegionCode" type="s:string" />  
  165.   </wsdl:message>  
  166.   <wsdl:message name="getSupportCityStringHttpGetOut">  
  167.     <wsdl:part name="Body" element="tns:ArrayOfString" />  
  168.   </wsdl:message>  
  169.   <wsdl:message name="getWeatherHttpGetIn">  
  170.     <wsdl:part name="theCityCode" type="s:string" />  
  171.     <wsdl:part name="theUserID" type="s:string" />  
  172.   </wsdl:message>  
  173.   <wsdl:message name="getWeatherHttpGetOut">  
  174.     <wsdl:part name="Body" element="tns:ArrayOfString" />  
  175.   </wsdl:message>  
  176.   <wsdl:message name="getRegionDatasetHttpPostIn" />  
  177.   <wsdl:message name="getRegionDatasetHttpPostOut">  
  178.     <wsdl:part name="Body" element="tns:DataSet" />  
  179.   </wsdl:message>  
  180.   <wsdl:message name="getRegionProvinceHttpPostIn" />  
  181.   <wsdl:message name="getRegionProvinceHttpPostOut">  
  182.     <wsdl:part name="Body" element="tns:ArrayOfString" />  
  183.   </wsdl:message>  
  184.   <wsdl:message name="getRegionCountryHttpPostIn" />  
  185.   <wsdl:message name="getRegionCountryHttpPostOut">  
  186.     <wsdl:part name="Body" element="tns:ArrayOfString" />  
  187.   </wsdl:message>  
  188.   <wsdl:message name="getSupportCityDatasetHttpPostIn">  
  189.     <wsdl:part name="theRegionCode" type="s:string" />  
  190.   </wsdl:message>  
  191.   <wsdl:message name="getSupportCityDatasetHttpPostOut">  
  192.     <wsdl:part name="Body" element="tns:DataSet" />  
  193.   </wsdl:message>  
  194.   <wsdl:message name="getSupportCityStringHttpPostIn">  
  195.     <wsdl:part name="theRegionCode" type="s:string" />  
  196.   </wsdl:message>  
  197.   <wsdl:message name="getSupportCityStringHttpPostOut">  
  198.     <wsdl:part name="Body" element="tns:ArrayOfString" />  
  199.   </wsdl:message>  
  200.   <wsdl:message name="getWeatherHttpPostIn">  
  201.     <wsdl:part name="theCityCode" type="s:string" />  
  202.     <wsdl:part name="theUserID" type="s:string" />  
  203.   </wsdl:message>  
  204.   <wsdl:message name="getWeatherHttpPostOut">  
  205.     <wsdl:part name="Body" element="tns:ArrayOfString" />  
  206.   </wsdl:message>  
  207.   <wsdl:portType name="WeatherWSSoap">  
  208.     <wsdl:operation name="getRegionDataset">  
  209.       <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"><br /><h3>获得中国省份、直辖市、地区;国家名称(国外)和与之对应的ID</h3><p>输入参数:无,返回数据:DataSet。</p><br /></wsdl:documentation>  
  210.       <wsdl:input message="tns:getRegionDatasetSoapIn" />  
  211.       <wsdl:output message="tns:getRegionDatasetSoapOut" />  
  212.     </wsdl:operation>  
  213.     <wsdl:operation name="getRegionProvince">  
  214.       <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"><br /><h3>获得中国省份、直辖市、地区和与之对应的ID</h3><p>输入参数:无,返回数据:一维字符串数组。</p><br /></wsdl:documentation>  
  215.       <wsdl:input message="tns:getRegionProvinceSoapIn" />  
  216.       <wsdl:output message="tns:getRegionProvinceSoapOut" />  
  217.     </wsdl:operation>  
  218.     <wsdl:operation name="getRegionCountry">  
  219.       <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"><br /><h3>获得国外国家名称和与之对应的ID</h3><p>输入参数:无,返回数据:一维字符串数组。</p><br /></wsdl:documentation>  
  220.       <wsdl:input message="tns:getRegionCountrySoapIn" />  
  221.       <wsdl:output message="tns:getRegionCountrySoapOut" />  
  222.     </wsdl:operation>  
  223.     <wsdl:operation name="getSupportCityDataset">  
  224.       <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"><br /><h3>获得支持的城市/地区名称和与之对应的ID</h3><p>输入参数:theRegionCode = 省市、国家ID或名称,返回数据:DataSet。</p><br /></wsdl:documentation>  
  225.       <wsdl:input message="tns:getSupportCityDatasetSoapIn" />  
  226.       <wsdl:output message="tns:getSupportCityDatasetSoapOut" />  
  227.     </wsdl:operation>  
  228.     <wsdl:operation name="getSupportCityString">  
  229.       <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"><br /><h3>获得支持的城市/地区名称和与之对应的ID</h3><p>输入参数:theRegionCode = 省市、国家ID或名称,返回数据:一维字符串数组。</p><br /></wsdl:documentation>  
  230.       <wsdl:input message="tns:getSupportCityStringSoapIn" />  
  231.       <wsdl:output message="tns:getSupportCityStringSoapOut" />  
  232.     </wsdl:operation>  
  233.     <wsdl:operation name="getWeather">  
  234.       <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"><br /><h3>获得天气预报数据</h3><p>输入参数:城市/地区ID或名称,返回数据:一维字符串数组。</p><br /></wsdl:documentation>  
  235.       <wsdl:input message="tns:getWeatherSoapIn" />  
  236.       <wsdl:output message="tns:getWeatherSoapOut" />  
  237.     </wsdl:operation>  
  238.   </wsdl:portType>  
  239.   <wsdl:portType name="WeatherWSHttpGet">  
  240.     <wsdl:operation name="getRegionDataset">  
  241.       <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"><br /><h3>获得中国省份、直辖市、地区;国家名称(国外)和与之对应的ID</h3><p>输入参数:无,返回数据:DataSet。</p><br /></wsdl:documentation>  
  242.       <wsdl:input message="tns:getRegionDatasetHttpGetIn" />  
  243.       <wsdl:output message="tns:getRegionDatasetHttpGetOut" />  
  244.     </wsdl:operation>  
  245.     <wsdl:operation name="getRegionProvince">  
  246.       <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"><br /><h3>获得中国省份、直辖市、地区和与之对应的ID</h3><p>输入参数:无,返回数据:一维字符串数组。</p><br /></wsdl:documentation>  
  247.       <wsdl:input message="tns:getRegionProvinceHttpGetIn" />  
  248.       <wsdl:output message="tns:getRegionProvinceHttpGetOut" />  
  249.     </wsdl:operation>  
  250.     <wsdl:operation name="getRegionCountry">  
  251.       <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"><br /><h3>获得国外国家名称和与之对应的ID</h3><p>输入参数:无,返回数据:一维字符串数组。</p><br /></wsdl:documentation>  
  252.       <wsdl:input message="tns:getRegionCountryHttpGetIn" />  
  253.       <wsdl:output message="tns:getRegionCountryHttpGetOut" />  
  254.     </wsdl:operation>  
  255.     <wsdl:operation name="getSupportCityDataset">  
  256.       <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"><br /><h3>获得支持的城市/地区名称和与之对应的ID</h3><p>输入参数:theRegionCode = 省市、国家ID或名称,返回数据:DataSet。</p><br /></wsdl:documentation>  
  257.       <wsdl:input message="tns:getSupportCityDatasetHttpGetIn" />  
  258.       <wsdl:output message="tns:getSupportCityDatasetHttpGetOut" />  
  259.     </wsdl:operation>  
  260.     <wsdl:operation name="getSupportCityString">  
  261.       <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"><br /><h3>获得支持的城市/地区名称和与之对应的ID</h3><p>输入参数:theRegionCode = 省市、国家ID或名称,返回数据:一维字符串数组。</p><br /></wsdl:documentation>  
  262.       <wsdl:input message="tns:getSupportCityStringHttpGetIn" />  
  263.       <wsdl:output message="tns:getSupportCityStringHttpGetOut" />  
  264.     </wsdl:operation>  
  265.     <wsdl:operation name="getWeather">  
  266.       <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"><br /><h3>获得天气预报数据</h3><p>输入参数:城市/地区ID或名称,返回数据:一维字符串数组。</p><br /></wsdl:documentation>  
  267.       <wsdl:input message="tns:getWeatherHttpGetIn" />  
  268.       <wsdl:output message="tns:getWeatherHttpGetOut" />  
  269.     </wsdl:operation>  
  270.   </wsdl:portType>  
  271.   <wsdl:portType name="WeatherWSHttpPost">  
  272.     <wsdl:operation name="getRegionDataset">  
  273.       <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"><br /><h3>获得中国省份、直辖市、地区;国家名称(国外)和与之对应的ID</h3><p>输入参数:无,返回数据:DataSet。</p><br /></wsdl:documentation>  
  274.       <wsdl:input message="tns:getRegionDatasetHttpPostIn" />  
  275.       <wsdl:output message="tns:getRegionDatasetHttpPostOut" />  
  276.     </wsdl:operation>  
  277.     <wsdl:operation name="getRegionProvince">  
  278.       <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"><br /><h3>获得中国省份、直辖市、地区和与之对应的ID</h3><p>输入参数:无,返回数据:一维字符串数组。</p><br /></wsdl:documentation>  
  279.       <wsdl:input message="tns:getRegionProvinceHttpPostIn" />  
  280.       <wsdl:output message="tns:getRegionProvinceHttpPostOut" />  
  281.     </wsdl:operation>  
  282.     <wsdl:operation name="getRegionCountry">  
  283.       <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"><br /><h3>获得国外国家名称和与之对应的ID</h3><p>输入参数:无,返回数据:一维字符串数组。</p><br /></wsdl:documentation>  
  284.       <wsdl:input message="tns:getRegionCountryHttpPostIn" />  
  285.       <wsdl:output message="tns:getRegionCountryHttpPostOut" />  
  286.     </wsdl:operation>  
  287.     <wsdl:operation name="getSupportCityDataset">  
  288.       <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"><br /><h3>获得支持的城市/地区名称和与之对应的ID</h3><p>输入参数:theRegionCode = 省市、国家ID或名称,返回数据:DataSet。</p><br /></wsdl:documentation>  
  289.       <wsdl:input message="tns:getSupportCityDatasetHttpPostIn" />  
  290.       <wsdl:output message="tns:getSupportCityDatasetHttpPostOut" />  
  291.     </wsdl:operation>  
  292.     <wsdl:operation name="getSupportCityString">  
  293.       <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"><br /><h3>获得支持的城市/地区名称和与之对应的ID</h3><p>输入参数:theRegionCode = 省市、国家ID或名称,返回数据:一维字符串数组。</p><br /></wsdl:documentation>  
  294.       <wsdl:input message="tns:getSupportCityStringHttpPostIn" />  
  295.       <wsdl:output message="tns:getSupportCityStringHttpPostOut" />  
  296.     </wsdl:operation>  
  297.     <wsdl:operation name="getWeather">  
  298.       <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"><br /><h3>获得天气预报数据</h3><p>输入参数:城市/地区ID或名称,返回数据:一维字符串数组。</p><br /></wsdl:documentation>  
  299.       <wsdl:input message="tns:getWeatherHttpPostIn" />  
  300.       <wsdl:output message="tns:getWeatherHttpPostOut" />  
  301.     </wsdl:operation>  
  302.   </wsdl:portType>  
  303.   <wsdl:binding name="WeatherWSSoap" type="tns:WeatherWSSoap">  
  304.     <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />  
  305.     <wsdl:operation name="getRegionDataset">  
  306.       <soap:operation soapAction="http://WebXml.com.cn/getRegionDataset" style="document" />  
  307.       <wsdl:input>  
  308.         <soap:body use="literal" />  
  309.       </wsdl:input>  
  310.       <wsdl:output>  
  311.         <soap:body use="literal" />  
  312.       </wsdl:output>  
  313.     </wsdl:operation>  
  314.     <wsdl:operation name="getRegionProvince">  
  315.       <soap:operation soapAction="http://WebXml.com.cn/getRegionProvince" style="document" />  
  316.       <wsdl:input>  
  317.         <soap:body use="literal" />  
  318.       </wsdl:input>  
  319.       <wsdl:output>  
  320.         <soap:body use="literal" />  
  321.       </wsdl:output>  
  322.     </wsdl:operation>  
  323.     <wsdl:operation name="getRegionCountry">  
  324.       <soap:operation soapAction="http://WebXml.com.cn/getRegionCountry" style="document" />  
  325.       <wsdl:input>  
  326.         <soap:body use="literal" />  
  327.       </wsdl:input>  
  328.       <wsdl:output>  
  329.         <soap:body use="literal" />  
  330.       </wsdl:output>  
  331.     </wsdl:operation>  
  332.     <wsdl:operation name="getSupportCityDataset">  
  333.       <soap:operation soapAction="http://WebXml.com.cn/getSupportCityDataset" style="document" />  
  334.       <wsdl:input>  
  335.         <soap:body use="literal" />  
  336.       </wsdl:input>  
  337.       <wsdl:output>  
  338.         <soap:body use="literal" />  
  339.       </wsdl:output>  
  340.     </wsdl:operation>  
  341.     <wsdl:operation name="getSupportCityString">  
  342.       <soap:operation soapAction="http://WebXml.com.cn/getSupportCityString" style="document" />  
  343.       <wsdl:input>  
  344.         <soap:body use="literal" />  
  345.       </wsdl:input>  
  346.       <wsdl:output>  
  347.         <soap:body use="literal" />  
  348.       </wsdl:output>  
  349.     </wsdl:operation>  
  350.     <wsdl:operation name="getWeather">  
  351.       <soap:operation soapAction="http://WebXml.com.cn/getWeather" style="document" />  
  352.       <wsdl:input>  
  353.         <soap:body use="literal" />  
  354.       </wsdl:input>  
  355.       <wsdl:output>  
  356.         <soap:body use="literal" />  
  357.       </wsdl:output>  
  358.     </wsdl:operation>  
  359.   </wsdl:binding>  
  360.   <wsdl:binding name="WeatherWSSoap12" type="tns:WeatherWSSoap">  
  361.     <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />  
  362.     <wsdl:operation name="getRegionDataset">  
  363.       <soap12:operation soapAction="http://WebXml.com.cn/getRegionDataset" style="document" />  
  364.       <wsdl:input>  
  365.         <soap12:body use="literal" />  
  366.       </wsdl:input>  
  367.       <wsdl:output>  
  368.         <soap12:body use="literal" />  
  369.       </wsdl:output>  
  370.     </wsdl:operation>  
  371.     <wsdl:operation name="getRegionProvince">  
  372.       <soap12:operation soapAction="http://WebXml.com.cn/getRegionProvince" style="document" />  
  373.       <wsdl:input>  
  374.         <soap12:body use="literal" />  
  375.       </wsdl:input>  
  376.       <wsdl:output>  
  377.         <soap12:body use="literal" />  
  378.       </wsdl:output>  
  379.     </wsdl:operation>  
  380.     <wsdl:operation name="getRegionCountry">  
  381.       <soap12:operation soapAction="http://WebXml.com.cn/getRegionCountry" style="document" />  
  382.       <wsdl:input>  
  383.         <soap12:body use="literal" />  
  384.       </wsdl:input>  
  385.       <wsdl:output>  
  386.         <soap12:body use="literal" />  
  387.       </wsdl:output>  
  388.     </wsdl:operation>  
  389.     <wsdl:operation name="getSupportCityDataset">  
  390.       <soap12:operation soapAction="http://WebXml.com.cn/getSupportCityDataset" style="document" />  
  391.       <wsdl:input>  
  392.         <soap12:body use="literal" />  
  393.       </wsdl:input>  
  394.       <wsdl:output>  
  395.         <soap12:body use="literal" />  
  396.       </wsdl:output>  
  397.     </wsdl:operation>  
  398.     <wsdl:operation name="getSupportCityString">  
  399.       <soap12:operation soapAction="http://WebXml.com.cn/getSupportCityString" style="document" />  
  400.       <wsdl:input>  
  401.         <soap12:body use="literal" />  
  402.       </wsdl:input>  
  403.       <wsdl:output>  
  404.         <soap12:body use="literal" />  
  405.       </wsdl:output>  
  406.     </wsdl:operation>  
  407.     <wsdl:operation name="getWeather">  
  408.       <soap12:operation soapAction="http://WebXml.com.cn/getWeather" style="document" />  
  409.       <wsdl:input>  
  410.         <soap12:body use="literal" />  
  411.       </wsdl:input>  
  412.       <wsdl:output>  
  413.         <soap12:body use="literal" />  
  414.       </wsdl:output>  
  415.     </wsdl:operation>  
  416.   </wsdl:binding>  
  417.   <wsdl:binding name="WeatherWSHttpGet" type="tns:WeatherWSHttpGet">  
  418.     <http:binding verb="GET" />  
  419.     <wsdl:operation name="getRegionDataset">  
  420.       <http:operation location="/getRegionDataset" />  
  421.       <wsdl:input>  
  422.         <http:urlEncoded />  
  423.       </wsdl:input>  
  424.       <wsdl:output>  
  425.         <mime:mimeXml part="Body" />  
  426.       </wsdl:output>  
  427.     </wsdl:operation>  
  428.     <wsdl:operation name="getRegionProvince">  
  429.       <http:operation location="/getRegionProvince" />  
  430.       <wsdl:input>  
  431.         <http:urlEncoded />  
  432.       </wsdl:input>  
  433.       <wsdl:output>  
  434.         <mime:mimeXml part="Body" />  
  435.       </wsdl:output>  
  436.     </wsdl:operation>  
  437.     <wsdl:operation name="getRegionCountry">  
  438.       <http:operation location="/getRegionCountry" />  
  439.       <wsdl:input>  
  440.         <http:urlEncoded />  
  441.       </wsdl:input>  
  442.       <wsdl:output>  
  443.         <mime:mimeXml part="Body" />  
  444.       </wsdl:output>  
  445.     </wsdl:operation>  
  446.     <wsdl:operation name="getSupportCityDataset">  
  447.       <http:operation location="/getSupportCityDataset" />  
  448.       <wsdl:input>  
  449.         <http:urlEncoded />  
  450.       </wsdl:input>  
  451.       <wsdl:output>  
  452.         <mime:mimeXml part="Body" />  
  453.       </wsdl:output>  
  454.     </wsdl:operation>  
  455.     <wsdl:operation name="getSupportCityString">  
  456.       <http:operation location="/getSupportCityString" />  
  457.       <wsdl:input>  
  458.         <http:urlEncoded />  
  459.       </wsdl:input>  
  460.       <wsdl:output>  
  461.         <mime:mimeXml part="Body" />  
  462.       </wsdl:output>  
  463.     </wsdl:operation>  
  464.     <wsdl:operation name="getWeather">  
  465.       <http:operation location="/getWeather" />  
  466.       <wsdl:input>  
  467.         <http:urlEncoded />  
  468.       </wsdl:input>  
  469.       <wsdl:output>  
  470.         <mime:mimeXml part="Body" />  
  471.       </wsdl:output>  
  472.     </wsdl:operation>  
  473.   </wsdl:binding>  
  474.   <wsdl:binding name="WeatherWSHttpPost" type="tns:WeatherWSHttpPost">  
  475.     <http:binding verb="POST" />  
  476.     <wsdl:operation name="getRegionDataset">  
  477.       <http:operation location="/getRegionDataset" />  
  478.       <wsdl:input>  
  479.         <mime:content type="application/x-www-form-urlencoded" />  
  480.       </wsdl:input>  
  481.       <wsdl:output>  
  482.         <mime:mimeXml part="Body" />  
  483.       </wsdl:output>  
  484.     </wsdl:operation>  
  485.     <wsdl:operation name="getRegionProvince">  
  486.       <http:operation location="/getRegionProvince" />  
  487.       <wsdl:input>  
  488.         <mime:content type="application/x-www-form-urlencoded" />  
  489.       </wsdl:input>  
  490.       <wsdl:output>  
  491.         <mime:mimeXml part="Body" />  
  492.       </wsdl:output>  
  493.     </wsdl:operation>  
  494.     <wsdl:operation name="getRegionCountry">  
  495.       <http:operation location="/getRegionCountry" />  
  496.       <wsdl:input>  
  497.         <mime:content type="application/x-www-form-urlencoded" />  
  498.       </wsdl:input>  
  499.       <wsdl:output>  
  500.         <mime:mimeXml part="Body" />  
  501.       </wsdl:output>  
  502.     </wsdl:operation>  
  503.     <wsdl:operation name="getSupportCityDataset">  
  504.       <http:operation location="/getSupportCityDataset" />  
  505.       <wsdl:input>  
  506.         <mime:content type="application/x-www-form-urlencoded" />  
  507.       </wsdl:input>  
  508.       <wsdl:output>  
  509.         <mime:mimeXml part="Body" />  
  510.       </wsdl:output>  
  511.     </wsdl:operation>  
  512.     <wsdl:operation name="getSupportCityString">  
  513.       <http:operation location="/getSupportCityString" />  
  514.       <wsdl:input>  
  515.         <mime:content type="application/x-www-form-urlencoded" />  
  516.       </wsdl:input>  
  517.       <wsdl:output>  
  518.         <mime:mimeXml part="Body" />  
  519.       </wsdl:output>  
  520.     </wsdl:operation>  
  521.     <wsdl:operation name="getWeather">  
  522.       <http:operation location="/getWeather" />  
  523.       <wsdl:input>  
  524.         <mime:content type="application/x-www-form-urlencoded" />  
  525.       </wsdl:input>  
  526.       <wsdl:output>  
  527.         <mime:mimeXml part="Body" />  
  528.       </wsdl:output>  
  529.     </wsdl:operation>  
  530.   </wsdl:binding>  
  531.   <span style="color:#ff6666;"><wsdl:service name="WeatherWS"></span>  
  532.     <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"><a href="http://www.webxml.com.cn/" target="_blank">WebXml.com.cn</a> <strong>2400多个城市天气预报Web服务</strong>,包含2300个以上中国城市和100个以上国外城市天气预报数据。数据每2.5小时左右自动更新一次,准确可靠。<br />使用本站 WEB 服务请注明或链接本站:<a href="http://www.webxml.com.cn/" target="_blank">http://www.webxml.com.cn/</a> 感谢大家的支持!<br /><br /><img alt="PDF" title="PDF file" src="http://www.webxml.com.cn/images/icon/pdf.gif" style="vertical-align: middle;" /> <a href="http://www.webxml.com.cn/files/WeatherWsHelp.pdf" target="_blank">接口帮助文档</a> &nbsp;&nbsp;&nbsp; <img alt="ZIP" title="ZIP file" src="http://www.webxml.com.cn/images/icon/zip.gif" style="vertical-align: middle;" /> <a href="http://www.webxml.com.cn/files/about_city.zip">部分城市介绍和气候背景</a> &nbsp;&nbsp;&nbsp; <img alt="ZIP" title="ZIP file" src="http://www.webxml.com.cn/images/icon/zip.gif" style="vertical-align: middle;" /> <a href="http://www.webxml.com.cn/files/city_photo.zip">部分城市图片</a> &nbsp;&nbsp;&nbsp; <img alt="HTML" title="HTML file" src="http://www.webxml.com.cn/images/icon/html.gif" style="vertical-align: middle;" /> <a href="http://www.webxml.com.cn/zh_cn/weather_icon.aspx" target="_blank">天气现象和图例</a><br />&nbsp;</wsdl:documentation>  
  533.     <wsdl:port name="WeatherWSSoap" binding="tns:WeatherWSSoap">  
  534.       <soap:address location="http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx" />  
  535.     </wsdl:port>  
  536.     <wsdl:port name="WeatherWSSoap12" binding="tns:WeatherWSSoap12">  
  537.       <soap12:address location="http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx" />  
  538.     </wsdl:port>  
  539.     <wsdl:port name="WeatherWSHttpGet" binding="tns:WeatherWSHttpGet">  
  540.       <http:address location="http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx" />  
  541.     </wsdl:port>  
  542.     <wsdl:port name="WeatherWSHttpPost" binding="tns:WeatherWSHttpPost">  
  543.       <http:address location="http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx" />  
  544.     </wsdl:port>  
  545.   </wsdl:service>  
  546. </wsdl:definitions>  

WebService简单入门教程可以参考以下文章:

http://www.cnblogs.com/yisheng163/p/4524808.html?utm_source=tuicool

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值