1. 程式人生 > >webservice 教程學習系列(七)——編寫天氣預報和手機號碼歸屬地的webservice

webservice 教程學習系列(七)——編寫天氣預報和手機號碼歸屬地的webservice

1.編寫天氣預報的webservice

 

首先我們在http://www.webxml.com.cn/zh_cn/index.aspx裡面找到天氣預報的url

然後找到獲取地區天氣的介面方法:

看到方法函式

得到URL連結:

然後在瀏覽器中輸入該URL:http://ws.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl

得到約束文字資訊:

然後新建java工程,在src下的dos視窗中解析url連結

會發現解析出錯:

原因是因為該webservice的server端是使用.net開發的,而我們是使用java的clien端呼叫的。

所以解決方法是,將該約束檔案儲存為本地的WSDL文字檔案,然後將其中所有的<s:element ref="s:schema" />  <s:any />替換成<s:any minOccurs="2" maxOccurs="2"/>即可。

貼一下report.wsdl的原始碼

<?xml version="1.0" encoding="utf-8"?>
<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/">
	<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">&lt;a
		href="http://www.webxml.com.cn/"
		target="_blank"&gt;WebXml.com.cn&lt;/a&gt;
		&lt;strong&gt;2400多個城市天氣預報Web服務&lt;/strong&gt;,包含2300個以上中國城市和100個以上國外城市天氣預報資料。資料每2.5小時左右自動更新一次,準確可靠。&lt;br
		/&gt;使用本站 WEB 服務請註明或連結本站:&lt;a href="http://www.webxml.com.cn/"
		target="_blank"&gt;http://www.webxml.com.cn/&lt;/a&gt; 感謝大家的支援!&lt;br
		/&gt;&lt;br /&gt;&lt;img alt="PDF" title="PDF file"
		src="http://www.webxml.com.cn/images/icon/pdf.gif"
		style="vertical-align: middle;" /&gt; &lt;a
		href="http://www.webxml.com.cn/files/WeatherWsHelp.pdf"
		target="_blank"&gt;介面幫助文件&lt;/a&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;
		&lt;img alt="ZIP" title="ZIP file"
		src="http://www.webxml.com.cn/images/icon/zip.gif"
		style="vertical-align: middle;" /&gt; &lt;a
		href="http://www.webxml.com.cn/files/about_city.zip"&gt;部分城市介紹和氣候背景&lt;/a&gt;
		&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;img alt="ZIP" title="ZIP file"
		src="http://www.webxml.com.cn/images/icon/zip.gif"
		style="vertical-align: middle;" /&gt; &lt;a
		href="http://www.webxml.com.cn/files/city_photo.zip"&gt;部分城市圖片&lt;/a&gt;
		&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;img alt="HTML" title="HTML file"
		src="http://www.webxml.com.cn/images/icon/html.gif"
		style="vertical-align: middle;" /&gt; &lt;a
		href="http://www.webxml.com.cn/zh_cn/weather_icon.aspx"
		target="_blank"&gt;天氣現象和圖例&lt;/a&gt;&lt;br /&gt;&amp;nbsp;
	</wsdl:documentation>
	<wsdl:types>
		<s:schema elementFormDefault="qualified" targetNamespace="http://WebXml.com.cn/">
			<s:element name="getRegionDataset">
				<s:complexType />
			</s:element>
			<s:element name="getRegionDatasetResponse">
				<s:complexType>
					<s:sequence>
						<s:element minOccurs="0" maxOccurs="1"
							name="getRegionDatasetResult">
							<s:complexType>
								<s:sequence>
									<s:any minOccurs="2" maxOccurs="2"/>
								</s:sequence>
							</s:complexType>
						</s:element>
					</s:sequence>
				</s:complexType>
			</s:element>
			<s:element name="getRegionProvince">
				<s:complexType />
			</s:element>
			<s:element name="getRegionProvinceResponse">
				<s:complexType>
					<s:sequence>
						<s:element minOccurs="0" maxOccurs="1"
							name="getRegionProvinceResult" type="tns:ArrayOfString" />
					</s:sequence>
				</s:complexType>
			</s:element>
			<s:complexType name="ArrayOfString">
				<s:sequence>
					<s:element minOccurs="0" maxOccurs="unbounded" name="string"
						nillable="true" type="s:string" />
				</s:sequence>
			</s:complexType>
			<s:element name="getRegionCountry">
				<s:complexType />
			</s:element>
			<s:element name="getRegionCountryResponse">
				<s:complexType>
					<s:sequence>
						<s:element minOccurs="0" maxOccurs="1"
							name="getRegionCountryResult" type="tns:ArrayOfString" />
					</s:sequence>
				</s:complexType>
			</s:element>
			<s:element name="getSupportCityDataset">
				<s:complexType>
					<s:sequence>
						<s:element minOccurs="0" maxOccurs="1" name="theRegionCode"
							type="s:string" />
					</s:sequence>
				</s:complexType>
			</s:element>
			<s:element name="getSupportCityDatasetResponse">
				<s:complexType>
					<s:sequence>
						<s:element minOccurs="0" maxOccurs="1"
							name="getSupportCityDatasetResult">
							<s:complexType>
								<s:sequence>
									<s:any minOccurs="2" maxOccurs="2"/>
								</s:sequence>
							</s:complexType>
						</s:element>
					</s:sequence>
				</s:complexType>
			</s:element>
			<s:element name="getSupportCityString">
				<s:complexType>
					<s:sequence>
						<s:element minOccurs="0" maxOccurs="1" name="theRegionCode"
							type="s:string" />
					</s:sequence>
				</s:complexType>
			</s:element>
			<s:element name="getSupportCityStringResponse">
				<s:complexType>
					<s:sequence>
						<s:element minOccurs="0" maxOccurs="1"
							name="getSupportCityStringResult" type="tns:ArrayOfString" />
					</s:sequence>
				</s:complexType>
			</s:element>
			<s:element name="getWeather">
				<s:complexType>
					<s:sequence>
						<s:element minOccurs="0" maxOccurs="1" name="theCityCode"
							type="s:string" />
						<s:element minOccurs="0" maxOccurs="1" name="theUserID"
							type="s:string" />
					</s:sequence>
				</s:complexType>
			</s:element>
			<s:element name="getWeatherResponse">
				<s:complexType>
					<s:sequence>
						<s:element minOccurs="0" maxOccurs="1" name="getWeatherResult"
							type="tns:ArrayOfString" />
					</s:sequence>
				</s:complexType>
			</s:element>
			<s:element name="DataSet" nillable="true">
				<s:complexType>
					<s:sequence>
						<s:any minOccurs="2" maxOccurs="2"/>
					</s:sequence>
				</s:complexType>
			</s:element>
			<s:element name="ArrayOfString" nillable="true"
				type="tns:ArrayOfString" />
		</s:schema>
	</wsdl:types>
	<wsdl:message name="getRegionDatasetSoapIn">
		<wsdl:part name="parameters" element="tns:getRegionDataset" />
	</wsdl:message>
	<wsdl:message name="getRegionDatasetSoapOut">
		<wsdl:part name="parameters" element="tns:getRegionDatasetResponse" />
	</wsdl:message>
	<wsdl:message name="getRegionProvinceSoapIn">
		<wsdl:part name="parameters" element="tns:getRegionProvince" />
	</wsdl:message>
	<wsdl:message name="getRegionProvinceSoapOut">
		<wsdl:part name="parameters" element="tns:getRegionProvinceResponse" />
	</wsdl:message>
	<wsdl:message name="getRegionCountrySoapIn">
		<wsdl:part name="parameters" element="tns:getRegionCountry" />
	</wsdl:message>
	<wsdl:message name="getRegionCountrySoapOut">
		<wsdl:part name="parameters" element="tns:getRegionCountryResponse" />
	</wsdl:message>
	<wsdl:message name="getSupportCityDatasetSoapIn">
		<wsdl:part name="parameters" element="tns:getSupportCityDataset" />
	</wsdl:message>
	<wsdl:message name="getSupportCityDatasetSoapOut">
		<wsdl:part name="parameters" element="tns:getSupportCityDatasetResponse" />
	</wsdl:message>
	<wsdl:message name="getSupportCityStringSoapIn">
		<wsdl:part name="parameters" element="tns:getSupportCityString" />
	</wsdl:message>
	<wsdl:message name="getSupportCityStringSoapOut">
		<wsdl:part name="parameters" element="tns:getSupportCityStringResponse" />
	</wsdl:message>
	<wsdl:message name="getWeatherSoapIn">
		<wsdl:part name="parameters" element="tns:getWeather" />
	</wsdl:message>
	<wsdl:message name="getWeatherSoapOut">
		<wsdl:part name="parameters" element="tns:getWeatherResponse" />
	</wsdl:message>
	<wsdl:message name="getRegionDatasetHttpGetIn" />
	<wsdl:message name="getRegionDatasetHttpGetOut">
		<wsdl:part name="Body" element="tns:DataSet" />
	</wsdl:message>
	<wsdl:message name="getRegionProvinceHttpGetIn" />
	<wsdl:message name="getRegionProvinceHttpGetOut">
		<wsdl:part name="Body" element="tns:ArrayOfString" />
	</wsdl:message>
	<wsdl:message name="getRegionCountryHttpGetIn" />
	<wsdl:message name="getRegionCountryHttpGetOut">
		<wsdl:part name="Body" element="tns:ArrayOfString" />
	</wsdl:message>
	<wsdl:message name="getSupportCityDatasetHttpGetIn">
		<wsdl:part name="theRegionCode" type="s:string" />
	</wsdl:message>
	<wsdl:message name="getSupportCityDatasetHttpGetOut">
		<wsdl:part name="Body" element="tns:DataSet" />
	</wsdl:message>
	<wsdl:message name="getSupportCityStringHttpGetIn">
		<wsdl:part name="theRegionCode" type="s:string" />
	</wsdl:message>
	<wsdl:message name="getSupportCityStringHttpGetOut">
		<wsdl:part name="Body" element="tns:ArrayOfString" />
	</wsdl:message>
	<wsdl:message name="getWeatherHttpGetIn">
		<wsdl:part name="theCityCode" type="s:string" />
		<wsdl:part name="theUserID" type="s:string" />
	</wsdl:message>
	<wsdl:message name="getWeatherHttpGetOut">
		<wsdl:part name="Body" element="tns:ArrayOfString" />
	</wsdl:message>
	<wsdl:message name="getRegionDatasetHttpPostIn" />
	<wsdl:message name="getRegionDatasetHttpPostOut">
		<wsdl:part name="Body" element="tns:DataSet" />
	</wsdl:message>
	<wsdl:message name="getRegionProvinceHttpPostIn" />
	<wsdl:message name="getRegionProvinceHttpPostOut">
		<wsdl:part name="Body" element="tns:ArrayOfString" />
	</wsdl:message>
	<wsdl:message name="getRegionCountryHttpPostIn" />
	<wsdl:message name="getRegionCountryHttpPostOut">
		<wsdl:part name="Body" element="tns:ArrayOfString" />
	</wsdl:message>
	<wsdl:message name="getSupportCityDatasetHttpPostIn">
		<wsdl:part name="theRegionCode" type="s:string" />
	</wsdl:message>
	<wsdl:message name="getSupportCityDatasetHttpPostOut">
		<wsdl:part name="Body" element="tns:DataSet" />
	</wsdl:message>
	<wsdl:message name="getSupportCityStringHttpPostIn">
		<wsdl:part name="theRegionCode" type="s:string" />
	</wsdl:message>
	<wsdl:message name="getSupportCityStringHttpPostOut">
		<wsdl:part name="Body" element="tns:ArrayOfString" />
	</wsdl:message>
	<wsdl:message name="getWeatherHttpPostIn">
		<wsdl:part name="theCityCode" type="s:string" />
		<wsdl:part name="theUserID" type="s:string" />
	</wsdl:message>
	<wsdl:message name="getWeatherHttpPostOut">
		<wsdl:part name="Body" element="tns:ArrayOfString" />
	</wsdl:message>
	<wsdl:portType name="WeatherWSSoap">
		<wsdl:operation name="getRegionDataset">
			<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">&lt;br
				/&gt;&lt;h3&gt;獲得中國省份、直轄市、地區;國家名稱(國外)和與之對應的ID&lt;/h3&gt;&lt;p&gt;輸入引數:無,返回資料:DataSet。&lt;/p&gt;&lt;br
				/&gt;</wsdl:documentation>
			<wsdl:input message="tns:getRegionDatasetSoapIn" />
			<wsdl:output message="tns:getRegionDatasetSoapOut" />
		</wsdl:operation>
		<wsdl:operation name="getRegionProvince">
			<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">&lt;br
				/&gt;&lt;h3&gt;獲得中國省份、直轄市、地區和與之對應的ID&lt;/h3&gt;&lt;p&gt;輸入引數:無,返回資料:一維字串陣列。&lt;/p&gt;&lt;br
				/&gt;</wsdl:documentation>
			<wsdl:input message="tns:getRegionProvinceSoapIn" />
			<wsdl:output message="tns:getRegionProvinceSoapOut" />
		</wsdl:operation>
		<wsdl:operation name="getRegionCountry">
			<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">&lt;br
				/&gt;&lt;h3&gt;獲得國外國家名稱和與之對應的ID&lt;/h3&gt;&lt;p&gt;輸入引數:無,返回資料:一維字串陣列。&lt;/p&gt;&lt;br
				/&gt;</wsdl:documentation>
			<wsdl:input message="tns:getRegionCountrySoapIn" />
			<wsdl:output message="tns:getRegionCountrySoapOut" />
		</wsdl:operation>
		<wsdl:operation name="getSupportCityDataset">
			<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">&lt;br
				/&gt;&lt;h3&gt;獲得支援的城市/地區名稱和與之對應的ID&lt;/h3&gt;&lt;p&gt;輸入引數:theRegionCode
				= 省市、國家ID或名稱,返回資料:DataSet。&lt;/p&gt;&lt;br /&gt;
			</wsdl:documentation>
			<wsdl:input message="tns:getSupportCityDatasetSoapIn" />
			<wsdl:output message="tns:getSupportCityDatasetSoapOut" />
		</wsdl:operation>
		<wsdl:operation name="getSupportCityString">
			<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">&lt;br
				/&gt;&lt;h3&gt;獲得支援的城市/地區名稱和與之對應的ID&lt;/h3&gt;&lt;p&gt;輸入引數:theRegionCode
				= 省市、國家ID或名稱,返回資料:一維字串陣列。&lt;/p&gt;&lt;br /&gt;
			</wsdl:documentation>
			<wsdl:input message="tns:getSupportCityStringSoapIn" />
			<wsdl:output message="tns:getSupportCityStringSoapOut" />
		</wsdl:operation>
		<wsdl:operation name="getWeather">
			<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">&lt;br
				/&gt;&lt;h3&gt;獲得天氣預報資料&lt;/h3&gt;&lt;p&gt;輸入引數:城市/地區ID或名稱,返回資料:一維字串陣列。&lt;/p&gt;&lt;br
				/&gt;</wsdl:documentation>
			<wsdl:input message="tns:getWeatherSoapIn" />
			<wsdl:output message="tns:getWeatherSoapOut" />
		</wsdl:operation>
	</wsdl:portType>
	<wsdl:portType name="WeatherWSHttpGet">
		<wsdl:operation name="getRegionDataset">
			<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">&lt;br
				/&gt;&lt;h3&gt;獲得中國省份、直轄市、地區;國家名稱(國外)和與之對應的ID&lt;/h3&gt;&lt;p&gt;輸入引數:無,返回資料:DataSet。&lt;/p&gt;&lt;br
				/&gt;</wsdl:documentation>
			<wsdl:input message="tns:getRegionDatasetHttpGetIn" />
			<wsdl:output message="tns:getRegionDatasetHttpGetOut" />
		</wsdl:operation>
		<wsdl:operation name="getRegionProvince">
			<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">&lt;br
				/&gt;&lt;h3&gt;獲得中國省份、直轄市、地區和與之對應的ID&lt;/h3&gt;&lt;p&gt;輸入引數:無,返回資料:一維字串陣列。&lt;/p&gt;&lt;br
				/&gt;</wsdl:documentation>
			<wsdl:input message="tns:getRegionProvinceHttpGetIn" />
			<wsdl:output message="tns:getRegionProvinceHttpGetOut" />
		</wsdl:operation>
		<wsdl:operation name="getRegionCountry">
			<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">&lt;br
				/&gt;&lt;h3&gt;獲得國外國家名稱和與之對應的ID&lt;/h3&gt;&lt;p&gt;輸入引數:無,返回資料:一維字串陣列。&lt;/p&gt;&lt;br
				/&gt;</wsdl:documentation>
			<wsdl:input message="tns:getRegionCountryHttpGetIn" />
			<wsdl:output message="tns:getRegionCountryHttpGetOut" />
		</wsdl:operation>
		<wsdl:operation name="getSupportCityDataset">
			<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">&lt;br
				/&gt;&lt;h3&gt;獲得支援的城市/地區名稱和與之對應的ID&lt;/h3&gt;&lt;p&gt;輸入引數:theRegionCode
				= 省市、國家ID或名稱,返回資料:DataSet。&lt;/p&gt;&lt;br /&gt;
			</wsdl:documentation>
			<wsdl:input message="tns:getSupportCityDatasetHttpGetIn" />
			<wsdl:output message="tns:getSupportCityDatasetHttpGetOut" />
		</wsdl:operation>
		<wsdl:operation name="getSupportCityString">
			<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">&lt;br
				/&gt;&lt;h3&gt;獲得支援的城市/地區名稱和與之對應的ID&lt;/h3&gt;&lt;p&gt;輸入引數:theRegionCode
				= 省市、國家ID或名稱,返回資料:一維字串陣列。&lt;/p&gt;&lt;br /&gt;
			</wsdl:documentation>
			<wsdl:input message="tns:getSupportCityStringHttpGetIn" />
			<wsdl:output message="tns:getSupportCityStringHttpGetOut" />
		</wsdl:operation>
		<wsdl:operation name="getWeather">
			<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">&lt;br
				/&gt;&lt;h3&gt;獲得天氣預報資料&lt;/h3&gt;&lt;p&gt;輸入引數:城市/地區ID或名稱,返回資料:一維字串陣列。&lt;/p&gt;&lt;br
				/&gt;</wsdl:documentation>
			<wsdl:input message="tns:getWeatherHttpGetIn" />
			<wsdl:output message="tns:getWeatherHttpGetOut" />
		</wsdl:operation>
	</wsdl:portType>
	<wsdl:portType name="WeatherWSHttpPost">
		<wsdl:operation name="getRegionDataset">
			<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">&lt;br
				/&gt;&lt;h3&gt;獲得中國省份、直轄市、地區;國家名稱(國外)和與之對應的ID&lt;/h3&gt;&lt;p&gt;輸入引數:無,返回資料:DataSet。&lt;/p&gt;&lt;br
				/&gt;</wsdl:documentation>
			<wsdl:input message="tns:getRegionDatasetHttpPostIn" />
			<wsdl:output message="tns:getRegionDatasetHttpPostOut" />
		</wsdl:operation>
		<wsdl:operation name="getRegionProvince">
			<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">&lt;br
				/&gt;&lt;h3&gt;獲得中國省份、直轄市、地區和與之對應的ID&lt;/h3&gt;&lt;p&gt;輸入引數:無,返回資料:一維字串陣列。&lt;/p&gt;&lt;br
				/&gt;</wsdl:documentation>
			<wsdl:input message="tns:getRegionProvinceHttpPostIn" />
			<wsdl:output message="tns:getRegionProvinceHttpPostOut" />
		</wsdl:operation>
		<wsdl:operation name="getRegionCountry">
			<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">&lt;br
				/&gt;&lt;h3&gt;獲得國外國家名稱和與之對應的ID&lt;/h3&gt;&lt;p&gt;輸入引數:無,返回資料:一維字串陣列。&lt;/p&gt;&lt;br
				/&gt;</wsdl:documentation>
			<wsdl:input message="tns:getRegionCountryHttpPostIn" />
			<wsdl:output message="tns:getRegionCountryHttpPostOut" />
		</wsdl:operation>
		<wsdl:operation name="getSupportCityDataset">
			<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">&lt;br
				/&gt;&lt;h3&gt;獲得支援的城市/地區名稱和與之對應的ID&lt;/h3&gt;&lt;p&gt;輸入引數:theRegionCode
				= 省市、國家ID或名稱,返回資料:DataSet。&lt;/p&gt;&lt;br /&gt;
			</wsdl:documentation>
			<wsdl:input message="tns:getSupportCityDatasetHttpPostIn" />
			<wsdl:output message="tns:getSupportCityDatasetHttpPostOut" />
		</wsdl:operation>
		<wsdl:operation name="getSupportCityString">
			<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">&lt;br
				/&gt;&lt;h3&gt;獲得支援的城市/地區名稱和與之對應的ID&lt;/h3&gt;&lt;p&gt;輸入引數:theRegionCode
				= 省市、國家ID或名稱,返回資料:一維字串陣列。&lt;/p&gt;&lt;br /&gt;
			</wsdl:documentation>
			<wsdl:input message="tns:getSupportCityStringHttpPostIn" />
			<wsdl:output message="tns:getSupportCityStringHttpPostOut" />
		</wsdl:operation>
		<wsdl:operation name="getWeather">
			<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">&lt;br
				/&gt;&lt;h3&gt;獲得天氣預報資料&lt;/h3&gt;&lt;p&gt;輸入引數:城市/地區ID或名稱,返回資料:一維字串陣列。&lt;/p&gt;&lt;br
				/&gt;</wsdl:documentation>
			<wsdl:input message="tns:getWeatherHttpPostIn" />
			<wsdl:output message="tns:getWeatherHttpPostOut" />
		</wsdl:operation>
	</wsdl:portType>
	<wsdl:binding name="WeatherWSSoap" type="tns:WeatherWSSoap">
		<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
		<wsdl:operation name="getRegionDataset">
			<soap:operation soapAction="http://WebXml.com.cn/getRegionDataset"
				style="document" />
			<wsdl:input>
				<soap:body use="literal" />
			</wsdl:input>
			<wsdl:output>
				<soap:body use="literal" />
			</wsdl:output>
		</wsdl:operation>
		<wsdl:operation name="getRegionProvince">
			<soap:operation soapAction="http://WebXml.com.cn/getRegionProvince"
				style="document" />
			<wsdl:input>
				<soap:body use="literal" />
			</wsdl:input>
			<wsdl:output>
				<soap:body use="literal" />
			</wsdl:output>
		</wsdl:operation>
		<wsdl:operation name="getRegionCountry">
			<soap:operation soapAction="http://WebXml.com.cn/getRegionCountry"
				style="document" />
			<wsdl:input>
				<soap:body use="literal" />
			</wsdl:input>
			<wsdl:output>
				<soap:body use="literal" />
			</wsdl:output>
		</wsdl:operation>
		<wsdl:operation name="getSupportCityDataset">
			<soap:operation soapAction="http://WebXml.com.cn/getSupportCityDataset"
				style="document" />
			<wsdl:input>
				<soap:body use="literal" />
			</wsdl:input>
			<wsdl:output>
				<soap:body use="literal" />
			</wsdl:output>
		</wsdl:operation>
		<wsdl:operation name="getSupportCityString">
			<soap:operation soapAction="http://WebXml.com.cn/getSupportCityString"
				style="document" />
			<wsdl:input>
				<soap:body use="literal" />
			</wsdl:input>
			<wsdl:output>
				<soap:body use="literal" />
			</wsdl:output>
		</wsdl:operation>
		<wsdl:operation name="getWeather">
			<soap:operation soapAction="http://WebXml.com.cn/getWeather"
				style="document" />
			<wsdl:input>
				<soap:body use="literal" />
			</wsdl:input>
			<wsdl:output>
				<soap:body use="literal" />
			</wsdl:output>
		</wsdl:operation>
	</wsdl:binding>
	<wsdl:binding name="WeatherWSSoap12" type="tns:WeatherWSSoap">
		<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
		<wsdl:operation name="getRegionDataset">
			<soap12:operation soapAction="http://WebXml.com.cn/getRegionDataset"
				style="document" />
			<wsdl:input>
				<soap12:body use="literal" />
			</wsdl:input>
			<wsdl:output>
				<soap12:body use="literal" />
			</wsdl:output>
		</wsdl:operation>
		<wsdl:operation name="getRegionProvince">
			<soap12:operation soapAction="http://WebXml.com.cn/getRegionProvince"
				style="document" />
			<wsdl:input>
				<soap12:body use="literal" />
			</wsdl:input>
			<wsdl:output>
				<soap12:body use="literal" />
			</wsdl:output>
		</wsdl:operation>
		<wsdl:operation name="getRegionCountry">
			<soap12:operation soapAction="http://WebXml.com.cn/getRegionCountry"
				style="document" />
			<wsdl:input>
				<soap12:body use="literal" />
			</wsdl:input>
			<wsdl:output>
				<soap12:body use="literal" />
			</wsdl:output>
		</wsdl:operation>
		<wsdl:operation name="getSupportCityDataset">
			<soap12:operation soapAction="http://WebXml.com.cn/getSupportCityDataset"
				style="document" />
			<wsdl:input>
				<soap12:body use="literal" />
			</wsdl:input>
			<wsdl:output>
				<soap12:body use="literal" />
			</wsdl:output>
		</wsdl:operation>
		<wsdl:operation name="getSupportCityString">
			<soap12:operation soapAction="http://WebXml.com.cn/getSupportCityString"
				style="document" />
			<wsdl:input>
				<soap12:body use="literal" />
			</wsdl:input>
			<wsdl:output>
				<soap12:body use="literal" />
			</wsdl:output>
		</wsdl:operation>
		<wsdl:operation name="getWeather">
			<soap12:operation soapAction="http://WebXml.com.cn/getWeather"
				style="document" />
			<wsdl:input>
				<soap12:body use="literal" />
			</wsdl:input>
			<wsdl:output>
				<soap12:body use="literal" />
			</wsdl:output>
		</wsdl:operation>
	</wsdl:binding>
	<wsdl:binding name="WeatherWSHttpGet" type="tns:WeatherWSHttpGet">
		<http:binding verb="GET" />
		<wsdl:operation name="getRegionDataset">
			<http:operation location="/getRegionDataset" />
			<wsdl:input>
				<http:urlEncoded />
			</wsdl:input>
			<wsdl:output>
				<mime:mimeXml part="Body" />
			</wsdl:output>
		</wsdl:operation>
		<wsdl:operation name="getRegionProvince">
			<http:operation location="/getRegionProvince" />
			<wsdl:input>
				<http:urlEncoded />
			</wsdl:input>
			<wsdl:output>
				<mime:mimeXml part="Body" />
			</wsdl:output>
		</wsdl:operation>
		<wsdl:operation name="getRegionCountry">
			<http:operation location="/getRegionCountry" />
			<wsdl:input>
				<http:urlEncoded />
			</wsdl:input>
			<wsdl:output>
				<mime:mimeXml part="Body" />
			</wsdl:output>
		</wsdl:operation>
		<wsdl:operation name="getSupportCityDataset">
			<http:operation location="/getSupportCityDataset" />
			<wsdl:input>
				<http:urlEncoded />
			</wsdl:input>
			<wsdl:output>
				<mime:mimeXml part="Body" />
			</wsdl:output>
		</wsdl:operation>
		<wsdl:operation name="getSupportCityString">
			<http:operation location="/getSupportCityString" />
			<wsdl:input>
				<http:urlEncoded />
			</wsdl:input>
			<wsdl:output>
				<mime:mimeXml part="Body" />
			</wsdl:output>
		</wsdl:operation>
		<wsdl:operation name="getWeather">
			<http:operation location="/getWeather" />
			<wsdl:input>
				<http:urlEncoded />
			</wsdl:input>
			<wsdl:output>
				<mime:mimeXml part="Body" />
			</wsdl:output>
		</wsdl:operation>
	</wsdl:binding>
	<wsdl:binding name="WeatherWSHttpPost" type="tns:WeatherWSHttpPost">
		<http:binding verb="POST" />
		<wsdl:operation name="getRegionDataset">
			<http:operation location="/getRegionDataset" />
			<wsdl:input>
				<mime:content type="application/x-www-form-urlencoded" />
			</wsdl:input>
			<wsdl:output>
				<mime:mimeXml part="Body" />
			</wsdl:output>
		</wsdl:operation>
		<wsdl:operation name="getRegionProvince">
			<http:operation location="/getRegionProvince" />
			<wsdl:input>
				<mime:content type="application/x-www-form-urlencoded" />
			</wsdl:input>
			<wsdl:output>
				<mime:mimeXml part="Body" />
			</wsdl:output>
		</wsdl:operation>
		<wsdl:operation name="getRegionCountry">
			<http:operation location="/getRegionCountry" />
			<wsdl:input>
				<mime:content type="application/x-www-form-urlencoded" />
			</wsdl:input>
			<wsdl:output>
				<mime:mimeXml part="Body" />
			</wsdl:output>
		</wsdl:operation>
		<wsdl:operation name="getSupportCityDataset">
			<http:operation location="/getSupportCityDataset" />
			<wsdl:input>
				<mime:content type="application/x-www-form-urlencoded" />
			</wsdl:input>
			<wsdl:output>
				<mime:mimeXml part="Body" />
			</wsdl:output>
		</wsdl:operation>
		<wsdl:operation name="getSupportCityString">
			<http:operation location="/getSupportCityString" />
			<wsdl:input>
				<mime:content type="application/x-www-form-urlencoded" />
			</wsdl:input>
			<wsdl:output>
				<mime:mimeXml part="Body" />
			</wsdl:output>
		</wsdl:operation>
		<wsdl:operation name="getWeather">
			<http:operation location="/getWeather" />
			<wsdl:input>
				<mime:content type="application/x-www-form-urlencoded" />
			</wsdl:input>
			<wsdl:output>
				<mime:mimeXml part="Body" />
			</wsdl:output>
		</wsdl:operation>
	</wsdl:binding>
	<wsdl:service name="WeatherWS">
		<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">&lt;a
			href="http://www.webxml.com.cn/"
			target="_blank"&gt;WebXml.com.cn&lt;/a&gt;
			&lt;strong&gt;2400多個城市天氣預報Web服務&lt;/strong&gt;,包含2300個以上中國城市和100個以上國外城市天氣預報資料。資料每2.5小時左右自動更新一次,準確可靠。&lt;br
			/&gt;使用本站 WEB 服務請註明或連結本站:&lt;a href="http://www.webxml.com.cn/"
			target="_blank"&gt;http://www.webxml.com.cn/&lt;/a&gt; 感謝大家的支援!&lt;br
			/&gt;&lt;br /&gt;&lt;img alt="PDF" title="PDF file"
			src="http://www.webxml.com.cn/images/icon/pdf.gif"
			style="vertical-align: middle;" /&gt; &lt;a
			href="http://www.webxml.com.cn/files/WeatherWsHelp.pdf"
			target="_blank"&gt;介面幫助文件&lt;/a&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;
			&lt;img alt="ZIP" title="ZIP file"
			src="http://www.webxml.com.cn/images/icon/zip.gif"
			style="vertical-align: middle;" /&gt; &lt;a
			href="http://www.webxml.com.cn/files/about_city.zip"&gt;部分城市介紹和氣候背景&lt;/a&gt;
			&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;img alt="ZIP" title="ZIP file"
			src="http://www.webxml.com.cn/images/icon/zip.gif"
			style="vertical-align: middle;" /&gt; &lt;a
			href="http://www.webxml.com.cn/files/city_photo.zip"&gt;部分城市圖片&lt;/a&gt;
			&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;img alt="HTML" title="HTML file"
			src="http://www.webxml.com.cn/images/icon/html.gif"
			style="vertical-align: middle;" /&gt; &lt;a
			href="http://www.webxml.com.cn/zh_cn/weather_icon.aspx"
			target="_blank"&gt;天氣現象和圖例&lt;/a&gt;&lt;br /&gt;&amp;nbsp;
		</wsdl:documentation>
		<wsdl:port name="WeatherWSSoap" binding="tns:WeatherWSSoap">
			<soap:address location="http://ws.webxml.com.cn/WebServices/WeatherWS.asmx" />
		</wsdl:port>
		<wsdl:port name="WeatherWSSoap12" binding="tns:WeatherWSSoap12">
			<soap12:address location="http://ws.webxml.com.cn/WebServices/WeatherWS.asmx" />
		</wsdl:port>
		<wsdl:port name="WeatherWSHttpGet" binding="tns:WeatherWSHttpGet">
			<http:address location="http://ws.webxml.com.cn/WebServices/WeatherWS.asmx" />
		</wsdl:port>
		<wsdl:port name="WeatherWSHttpPost" binding="tns:WeatherWSHttpPost">
			<http:address location="http://ws.webxml.com.cn/WebServices/WeatherWS.asmx" />
		</wsdl:port>
	</wsdl:service>
</wsdl:definitions>

然後在dos視窗中,使用文字解析即可。

雖然有警告,但是生成檔案了 。

然後我們嘗試呼叫這個天氣預報的介面:

所以根檔案是WeatherWS

客戶端呼叫程式碼:

package cn.com.webxml.test;

import java.util.List;

import cn.com.webxml.ArrayOfString;
import cn.com.webxml.WeatherWS;
import cn.com.webxml.WeatherWSSoap;

public class WSReportTest {

	public static void main(String[] args) {
		WeatherWS  weatherWS=new WeatherWS();
		WeatherWSSoap weatherWSSoap = weatherWS.getWeatherWSSoap();
		ArrayOfString weather = weatherWSSoap.getWeather("北京", null);
		List<String> list = weather.getString();

		for(String str:list){

			System.out.println(str);

		}

	}

}

執行結果為:

同理,可以嘗試呼叫國內手機號碼歸屬地查詢WEB服務。

2.編寫手機號碼歸屬地的webservice

url地址:http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx?op=getMobileCodeInfo

wsdl的連結:http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl

呼叫程式碼:

package cn.com.webxml.test;

import cn.com.webxml.MobileCodeWS;
import cn.com.webxml.MobileCodeWSSoap;

public class WSModelTest {

	public static void main(String[] args) {
		MobileCodeWS mobileCodeWS=new MobileCodeWS();
		MobileCodeWSSoap mobileCodeWSSoap = mobileCodeWS.getMobileCodeWSSoap();
		String mobileCodeInfo = mobileCodeWSSoap.getMobileCodeInfo("15713329014", null);
		System.out.println(mobileCodeInfo);
	}

}

執行結果:

其他介面的呼叫也是類似,不再贅述。