WebService - WSDL报错 <s:element ref="s:schema" /><s:any />

本文介绍了一个免费的城市天气预报WebService接口,提供了获取2400多个城市的天气预报数据的方法,包括2300个以上中国城市和100个以上国外城市的数据。详细解释了如何通过SOAP、HTTP GET及POST请求获取城市列表、地区列表和天气预报。

【1】获取wsdl

这里获取的时免费webservice接口–城市天气。

http://ws.webxml.com.cn/WebServices/WeatherWS.asmx?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:element ref="s:schema" />
                  <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:element ref="s:schema" />
                  <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:element ref="s:schema" />
            <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/">&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>

【2】eclipse提示报错

这里写图片描述


【3】解决办法

<s:element ref="s:schema" /> <s:any />全部替换为
<s:any minOccurs="2" maxOccurs="2" />
String localPart参数指的是一下wdsl文件的那个参数;<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://webservice.mes.service.basic.example.com" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="MesWebServiceImplService" targetNamespace="http://webservice.mes.service.basic.example.com"> <wsdl:types> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://webservice.mes.service.basic.example.com" elementFormDefault="unqualified" targetNamespace="http://webservice.mes.service.basic.example.com" version="1.0"> <xs:element name="getAllTechByProCode" type="tns:getAllTechByProCode"/> <xs:element name="getAllTechByProCodeResponse" type="tns:getAllTechByProCodeResponse"/> <xs:complexType name="getAllTechByProCode"> <xs:sequence> <xs:element minOccurs="0" name="productCode" type="xs:string"/> </xs:sequence> </xs:complexType> <xs:complexType name="getAllTechByProCodeResponse"> <xs:sequence> <xs:element minOccurs="0" name="return" type="tns:result"/> </xs:sequence> </xs:complexType> <xs:complexType name="result"> <xs:sequence> <xs:element minOccurs="0" name="code" type="xs:int"/> <xs:element minOccurs="0" name="data" type="xs:anyType"/> <xs:element minOccurs="0" name="msg" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:schema> </wsdl:types> <wsdl:message name="getAllTechByProCodeResponse"> <wsdl:part element="tns:getAllTechByProCodeResponse" name="parameters"> </wsdl:part> </wsdl:message> <wsdl:message name="getAllTechByProCode"> <wsdl:part element="tns:getAllTechByProCode" name="parameters"> </wsdl:part> </wsdl:message> <wsdl:portType name="IMesWebService"> <wsdl:operation name="getAllTechByProCode"> <wsdl:input message="tns:getAllTechByProCode" name="getAllTechByProCode"> </wsdl:input> <wsdl:output message="tns:getAllTechByProCodeResponse" name="getAllTechByProCodeResponse"> </wsdl:output> </wsdl:operation> </wsdl:portType> <wsdl:bindi
最新发布
03-13
<think>好的,用户的问题是关于在WSDL文件中找到对应于String localPart参数的消息部分或元素。我需要根据提供的引用内容来解答这个问题。首先,用户引用了三个不同的来源,其中引用[1]提到了@PayloadRoot注解中的localPart属性,引用[2]讨论了添加参数到call对象,而引用[3]是关于组件扫描的,可能不太相关。 首先,我需要理解localPart在Web服务中的作用。根据引用[1],@PayloadRoot的localPart属性用于指定处理程序方法处理的XML元素的本地名称。这意味着在WSDL中,这个localPart应该对应某个具体的请求元素名称。例如,如果某个方法被注解为@PayloadRoot(namespace = "http://example.com", localPart = "MyRequest"),那么在WSDL中应该有一个命名空间为http://example.com的元素MyRequest。 接下来,引用[2]提到在调用Web服务时添加参数,例如arg0、arg1等,类型为String。这可能意味着在SOAP请求中,这些参数会被包装在一个元素中,而该元素的名称就是localPart指定的值。因此,在WSDL中需要查找与这些参数对应的消息部分,可能是在types部分定义的元素,或者在portType和binding部分的操作中引用的消息。 可能的步骤是: 1. 在WSDL的types部分查找与目标命名空间对应的schema,找到与localPart名称匹配的元素。 2. 检查portType中的操作,特别是输入消息,确定引用的消息部分。 3. 在消息部分中,查看每个part对应的元素,匹配localPart的名称和命名空间。 需要注意,WSDL的结构可能比较复杂,不同的部分如message、portType、binding、types需要相互关联。用户需要根据@PayloadRoot注解中的namespace和localPart值,在WSDL的相应位置找到对应的元素。例如,如果注解中的namespace是"http://example.com/ws",localPart是"getDataRequest",那么在WSDL的types部分应该有一个该命名空间下的getDataRequest元素定义。 此外,用户可能需要检查SOAP请求的示例结构,确认参数是如何封装的。如果参数被包装在一个复合类型中,可能需要进一步解析该类型的结构,找到对应的String类型参数的位置。 总结来说,用户需要根据@PayloadRoot的namespace和localPart属性,在WSDL的types部分找到对应的元素,并确认该元素的结构是否包含String类型的参数。同时,结合调用时添加的参数名(如arg0),可能需要查看消息定义中的part名称或元素属性,以确定对应的位置。</think>### 逐步解答 在 WSDL 文件中定位与 `String localPart` 参数对应的元素需要以下步骤: #### 1. **理解 `localPart` 的上下文** - 根据引用[1],`@PayloadRoot` 注解中的 `localPart` 表示 **XML 元素的本地名称**,例如: 若注解为 `@PayloadRoot(namespace = "http://example.com/ws", localPart = "getDataRequest")`,则对应的 XML 元素名为 `getDataRequest`,且属于命名空间 `http://example.com/ws`[^1]。 - 在调用时,`call.addParameter("arg0", XMLType.XSD_STRING, ...)` 中的 `arg0` 是参数名,需对应到 XML 元素中的具体字段名[^2]。 #### 2. **在 WSDL 中定位元素** - **查找 `types` 部分**: WSDL 的 `<types>` 部分定义了 XML Schema(XSD)。需在 `schema` 中搜索与 `namespace` 匹配的目标命名空间,并找到 `localPart` 对应的元素。 例如: ```xml <xs:schema targetNamespace="http://example.com/ws"> <xs:element name="getDataRequest"> <xs:complexType> <xs:sequence> <xs:element name="arg0" type="xs:string"/> <!-- 对应 String 参数 --> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> ``` 这里 `arg0` 对应 `call.addParameter` 中的参数名,`getDataRequest` 对应 `@PayloadRoot` 的 `localPart`[^2]。 - **检查 `message` 和 `portType` 部分**: `<message>` 定义输入输出参数的结构。例如: ```xml <message name="getDataRequestMessage"> <part name="parameters" element="tns:getDataRequest"/> <!-- 引用上述元素 --> </message> <portType name="DataServicePortType"> <operation name="getData"> <input message="tns:getDataRequestMessage"/> <!-- 输入消息 --> </operation> </portType> ``` #### 3. **验证参数类型** - 在 XML Schema 中,`String` 类型对应 `xs:string`。确保目标元素的类型声明为 `type="xs:string"` 或类似类型。 #### 4. **工具辅助(可选)** - 使用 **SoapUI** 或 **WSDL 浏览器** 导入 WSDL 文件,自动生成请求模板,直接观察参数结构。 --- ### 示例总结 假设 WSDL 中存在以下定义: ```xml <definitions targetNamespace="http://example.com/ws"> <types> <xs:schema targetNamespace="http://example.com/ws"> <xs:element name="submitFormRequest"> <xs:complexType> <xs:sequence> <xs:element name="username" type="xs:string"/> <!-- 对应 arg0 --> <xs:element name="password" type="xs:string"/> <!-- 对应 arg1 --> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> </types> <message name="submitFormInput"> <part name="body" element="tns:submitFormRequest"/> </message> </definitions> ``` - 若代码中 `localPart = "submitFormRequest"`,则对应 `<xs:element name="submitFormRequest">`。 - `call.addParameter("arg0", XMLType.XSD_STRING, ...)` 对应 `<xs:element name="username">`。 ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

流烟默

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值