webservice获取天气信息
效果
1、eclipse中新建一个Java项目
2、通过命名获取天气的客户端信息
首先,打开天气网站http://ws.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl
然后,在Java项目的src目录下,新建一个文档weather.wsdl,文件名可以不一样
打开文件,把天气网站的所有文字复制粘贴到这个文件中
<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/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://WebXml.com.cn/">
<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>
<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 />
</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 />
</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 />
</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/">
<br />
<h3>获得中国省份、直辖市、地区;国家名称(国外)和与之对应的ID</h3>
<p>输入参数:无,返回数据:DataSet。</p>
<br />
</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/">
<br />
<h3>获得中国省份、直辖市、地区和与之对应的ID</h3>
<p>输入参数:无,返回数据:一维字符串数组。</p>
<br />
</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/">
<br />
<h3>获得国外国家名称和与之对应的ID</h3>
<p>输入参数:无,返回数据:一维字符串数组。</p>
<br />
</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/">
<br />
<h3>获得支持的城市/地区名称和与之对应的ID</h3>
<p>输入参数:theRegionCode = 省市、国家ID或名称,返回数据:DataSet。</p>
<br />
</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/">
<br />
<h3>获得支持的城市/地区名称和与之对应的ID</h3>
<p>输入参数:theRegionCode = 省市、国家ID或名称,返回数据:一维字符串数组。</p>
<br />
</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/">
<br />
<h3>获得天气预报数据</h3>
<p>输入参数:城市/地区ID或名称,返回数据:一维字符串数组。</p>
<br />
</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/">
<br />
<h3>获得中国省份、直辖市、地区;国家名称(国外)和与之对应的ID</h3>
<p>输入参数:无,返回数据:DataSet。</p>
<br />
</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/">
<br />
<h3>获得中国省份、直辖市、地区和与之对应的ID</h3>
<p>输入参数:无,返回数据:一维字符串数组。</p>
<br />
</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/">
<br />
<h3>获得国外国家名称和与之对应的ID</h3>
<p>输入参数:无,返回数据:一维字符串数组。</p>
<br />
</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/">
<br />
<h3>获得支持的城市/地区名称和与之对应的ID</h3>
<p>输入参数:theRegionCode = 省市、国家ID或名称,返回数据:DataSet。</p>
<br />
</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/">
<br />
<h3>获得支持的城市/地区名称和与之对应的ID</h3>
<p>输入参数:theRegionCode = 省市、国家ID或名称,返回数据:一维字符串数组。</p>
<br />
</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/">
<br />
<h3>获得天气预报数据</h3>
<p>输入参数:城市/地区ID或名称,返回数据:一维字符串数组。</p>
<br />
</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/">
<br />
<h3>获得中国省份、直辖市、地区;国家名称(国外)和与之对应的ID</h3>
<p>输入参数:无,返回数据:DataSet。</p>
<br />
</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/">
<br />
<h3>获得中国省份、直辖市、地区和与之对应的ID</h3>
<p>输入参数:无,返回数据:一维字符串数组。</p>
<br />
</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/">
<br />
<h3>获得国外国家名称和与之对应的ID</h3>
<p>输入参数:无,返回数据:一维字符串数组。</p>
<br />
</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/">
<br />
<h3>获得支持的城市/地区名称和与之对应的ID</h3>
<p>输入参数:theRegionCode = 省市、国家ID或名称,返回数据:DataSet。</p>
<br />
</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/">
<br />
<h3>获得支持的城市/地区名称和与之对应的ID</h3>
<p>输入参数:theRegionCode = 省市、国家ID或名称,返回数据:一维字符串数组。</p>
<br />
</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/">
<br />
<h3>获得天气预报数据</h3>
<p>输入参数:城市/地区ID或名称,返回数据:一维字符串数组。</p>
<br />
</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/">
<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>
<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>
weather.wsdl
接着,到这个文件中,Ctrl+F,把<s:element ref="s:schema" />全部删除
还要把 替换为&nbsp;
最后,win+R打开运行,输入cmd,到新建项目的src目录下,输入命令wsimport -keep weather.wsdl(后面这个是文件名)
注:如果发生以下提示(wsimport 不是内部或外部命令,也不是可运行的程序或批处理文件)
解决方法,参考文章:https://blog.csdn.net/jiudihanbing/article/details/52382508
3、创建开启客户端
package cn.com.webxml; import java.net.MalformedURLException;
import java.net.URL;
import java.util.List; import javax.xml.namespace.QName;
import javax.xml.ws.Service; /**
* @desc 客户端
* @author xiaostudy
*
*/
public class MyClient { public static void main(String[] args) {
//=============================================================================
//第一种方式获取视图
WeatherWS weatherWS = new WeatherWS();
//获取服务实现类
WeatherWSSoap weatherWSSoap = weatherWS.getPort(WeatherWSSoap.class);
//============================================================================= //=============================================================================
//第二种方式获取视图
/*URL url = null;
try {
url = new URL("http://ws.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl");
} catch (MalformedURLException e) {
e.printStackTrace();
} QName qName = new QName("http://WebXml.com.cn/", "WeatherWS"); Service service = Service.create(url, qName);
WeatherWSSoap weatherWSSoap = service.getPort(WeatherWSSoap.class);*/
//============================================================================= //调用服务器接口,发送数据并返回数据
ArrayOfString arrayOfString = weatherWSSoap.getWeather("广州", "");
//控制台打印数据
List<String> list = arrayOfString.getString();
for(String str : list) {
System.out.println(str);
}
} }
MyClient.java
package cn.com.webxml; import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL; /**
* @desc 客户端
* @author xiaostudy
*
*/
public class MyClient3 { public static void main(String[] args) {
try {
//第一步:创建服务地址,不是WSDL地址
URL url = new URL("http://ws.webxml.com.cn/WebServices/WeatherWS.asmx");
//第二步:打开一个通向服务地址的连接
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
//第三步:设置参数
//3.1发送方式设置:POST必须大写
connection.setRequestMethod("POST");
//3.2设置数据格式:content-type
connection.setRequestProperty("content-type", "text/xml;charset=utf-8");
//3.3设置输入输出,因为默认新创建的connection没有读写权限
connection.setDoInput(true);
connection.setDoOutput(true);
//第四步:组织SOAP数据,发送请求
String xml = getXml("广州");
OutputStream os = connection.getOutputStream();
os.write(xml.getBytes());
//第五步:接收服务端响应,打印
int responseCode = connection.getResponseCode();
//5.1判断响应吗是否为200(200表示一切正常)
if(responseCode == 200) {
//读取数据
InputStream is = connection.getInputStream();
//转化为字符流
InputStreamReader isr = new InputStreamReader(is);
//包装
BufferedReader br = new BufferedReader(isr);
StringBuffer sb = new StringBuffer();
String temp = null;
while(null != (temp = br.readLine())) {
sb.append(temp);
}
System.out.println(sb.toString()); //关闭资源
if(is != null) {
is.close();
is = null;
}
if(isr != null) {
isr.close();
isr = null;
}
if(br != null) {
br.close();
br = null;
}
if(os != null) {
os.close();
os = null;
}
}
} catch (IOException e) {
e.printStackTrace();
} } /**
* @desc 封装数据的方法
* @param str 参数,城市名
* @return String 返回类型,返回数据
*/
private static String getXml(String str) {
//前面两行和后面两行是固定格式,
//<getWeather>是调用的方法
//<theCityCode>和<theUserID>是调用方法里面的参数
String soapXML = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+"<soap:Envelope xmlns: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>"
+"<getWeather xmlns=\"http://WebXml.com.cn/\">"
+"<theCityCode>"+str+"</theCityCode>"
+"<theUserID></theUserID>"
+"</getWeather>"
+"</soap:Body>"
+"</soap:Envelope>";
return soapXML;
} }
MyClient3.java
4、运行客户端看结果,右键Run As→Java Application
webservice获取天气信息的更多相关文章
- Kettle通过Webservice获取天气信息
Kettle通过Webservice获取天气信息 需求: 通过kettle工具,通过webservice获取天气信息,写成xml格式文件. 思路: Kettle可通过两种选择获取webservic ...
- C#调用WebService获取天气信息
概述 本文使用C#开发Winform应用程序,通过调用<WebXml/>(URL:http://www.webxml.com.cn)的WebService服务WeatherWS来获取天气预 ...
- Java通过webservice接口获取天气信息
通过SOAP请求的方式获取天气信息并解析返回的XML文件. 参考: http://www.webxml.com.cn/WebServices/WeatherWS.asmx import java.io ...
- 内网公告牌获取天气信息解决方案(C# WebForm)
需求:内网公告牌能够正确显示未来三天的天气信息 本文关键字:C#/WebForm/Web定时任务/Ajax跨域 规划: 1.天定时读取百度接口获取天气信息并存储至Txt文档: 2.示牌开启时请求Web ...
- ajax无刷新获取天气信息
浏览器由于安全方面的问题,禁止ajax跨域请求其他网站的数据,但是可以再本地的服务器上获取其他服务器的信息,在通过ajax请求本地服务来实现: <?php header("conten ...
- 半吊子学习Swift--天气预报程序-获取天气信息
昨天申请的彩云天气Api开发者今天上午已审核通过  饭后运动过后就马不停蹄的来测试接口,接口是采用经纬度的方式来获取天气信息,接口地址如下 https://api.caiyunapp.com/v2/ ...
- java获取天气信息
通过天气信息接口获取天气信息,首先要给项目导入程序所需要的包,具体需要如下几个包: json-lib-2.4.jar ezmorph-1.0.6.jar commons-beanutils-1.8.3 ...
- Android实现自动定位城市并获取天气信息
定位实现代码: <span style="font-size:14px;">import java.io.IOException; import java.util.L ...
- java解析xml实例——获取天气信息
获取xml并解析其中的数据: package getweather.xml; import java.io.IOException; import java.util.HashMap; import ...
随机推荐
- Spark源码分析 – SparkEnv
SparkEnv在两个地方会被创建, 由于SparkEnv中包含了很多重要的模块, 比如BlockManager, 所以SparkEnv很重要 Driver端, 在SparkContext初始化的时候 ...
- Spring Data 之 Repository 接口
1. 介绍 Repository是一个空接口,即是一个标记性接口; 若我们定义的接口继承了Repository,则该接口会被IOC容器识别为一个 Repository Bean; 也可以通过@Repo ...
- Robberies---hdu2955(概率dp,01背包)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2955 题目给了每个银行的钱和被抓的概率,由于要抢尽量多的钱,所以要保证尽量不被抓,而抢多个银行之后不被 ...
- RE合同记账会计凭证
*&---------------------------------------------------------------------* *& Title : 不动产转租合同自 ...
- Spark2.0机器学习系列之6:GBDT(梯度提升决策树)、GBDT与随机森林差异、参数调试及Scikit代码分析
概念梳理 GBDT的别称 GBDT(Gradient Boost Decision Tree),梯度提升决策树. GBDT这个算法还有一些其他的名字,比如说MART(Multiple Addi ...
- 《闪存问题之READ DISTURB》总结
来自 http://www.ssdfans.com/?p=1778 闪存存在几个问题,影响着数据可靠性: 1.擦除次数,闪存擦除次数增多,会使隔离栅极的电化学键变弱. 2.data retention ...
- HMM,MEMM,CRF模型的比较
本文参考自:http://blog.csdn.net/happyzhouxiaopei/article/details/7960876 这三个模型都可以用来做序列标注模型.但是其各自有自身的特点,HM ...
- c#在线手册汇总
1. c#中文手册(脚本之家) http://shouce.jb51.net/net/
- 基于docker的gitlab+gitlabrunner+ansible自动部署
系统架构图 网络架构 一.安装docker,确保hostname没有问题 ,查看/etc/hostname./etc/hosts. https://docs.docker.com/engine/ins ...
- 64位win2003/win2008系统IIS6.0/7.5配置PHP的方法
64位win2003/win2008系统IIS6.0/7.5配置PHP的方法 32位的win2003系统配置PHP,估计很多人都已经驾轻就熟了,不过当遇到64位的系统时,估计又会遇上新的问题了.本文记 ...