0

郡/州の0個以上の気象警報とともに現在の天気予報を含むデータセットオブジェクトを返すWebサービスがあります。データセットオブジェクトには、WeatherオブジェクトとAlertsオブジェクトの配列が含まれているだけです。このクライアントの1つは、アラートではなく天気を最初に応答するように設定したいと考えています。応答エレメントの順序を指定する方法はありますか?WSDLを変更して、最初に天気をマップし、次にアラートをマップすることができると思いましたが、それでは何も起こりませんでした。

一般的なWSDLシートは次のとおりです
(プレビューではフォーマット済みでしたが、投稿後は表示されませんでした...フォーマット済みのXMLをここに投稿するにはどうすればよいですか?プリとコードだけでなく、バ​​ックティックを使用してみました)。

<wsdl:definitions ...>
 <wsdl:types>
  <schema elementFormDefault="qualified" targetNamespace="http://ws.sample.com" xmlns="http://www.w3.org/2001/XMLSchema">
   <import namespace="http://objects.sample.com"/>
   <element name="getAll">
    <complexType>
     <sequence>
      <element name="county" type="xsd:string"/>
      <element name="state" type="xsd:string"/>
      <element name="latitude" type="xsd:double"/>
      <element name="longitude" type="xsd:double"/>
     </sequence>
    </complexType>
   </element>
   <element name="getAllResponse">
    <complexType>
     <sequence>
      <element name="getAllReturn" type="tns1:DataSet"/>
     </sequence>
    </complexType>
   </element>
   <complexType name="ArrayOf_tns1_Alert">
    <sequence>
     <element maxOccurs="unbounded" minOccurs="0" name="item" type="tns1:Alert"/>
    </sequence>
   </complexType>
  </schema>
  <schema elementFormDefault="qualified" targetNamespace="http://objects.sample.com" xmlns="http://www.w3.org/2001/XMLSchema">
   <import namespace="http://ws.sample.com"/>
   <complexType name="Alert">
    <sequence>
     <element name="county" nillable="true" type="xsd:string"/>
     <element name="endDate" nillable="true" type="xsd:dateTime"/>
     <element name="locationCode" nillable="true" type="xsd:string"/>
     <element name="startDate" nillable="true" type="xsd:dateTime"/>
     <element name="state" nillable="true" type="xsd:string"/>
     <element name="title" nillable="true" type="xsd:string"/>
     <element name="warning" nillable="true" type="xsd:string"/>
    </sequence>
   </complexType>
   <complexType name="Weather">
    <sequence>
     <element name="chancePrecipitation" type="xsd:int"/>
     <element name="period" nillable="true" type="xsd:string"/>
     <element name="skyConditions" nillable="true" type="xsd:string"/>
     <element name="temperature" type="xsd:int"/>
     <element name="temperatureType" nillable="true" type="xsd:string"/>
     <element name="temperatureUnit" nillable="true" type="xsd:string"/>
     <element name="windDirection" nillable="true" type="xsd:string"/>
     <element name="windSpeed" type="xsd:int"/>
     <element name="windUnit" nillable="true" type="xsd:string"/>
    </sequence>
   </complexType>
   <complexType name="DataSet">
    <sequence>
     <element name="weather" nillable="true" type="tns1:Weather"/>
     <element name="alert" nillable="true" type="impl:ArrayOf_tns1_Alert"/>
    </sequence>
   </complexType>
  </schema>
 </wsdl:types>
   <wsdl:message name="getAllResponse">
      <wsdl:part element="impl:getAllResponse" name="parameters"/>
   </wsdl:message>
   <wsdl:message name="getAllRequest">
      <wsdl:part element="impl:getAll" name="parameters"/>
   </wsdl:message>
   <wsdl:portType name="TSTWeather">
      <wsdl:operation name="getAll">
         <wsdl:input message="impl:getAllRequest" name="getAllRequest"/>
         <wsdl:output message="impl:getAllResponse" name="getAllResponse"/>
      </wsdl:operation>
   </wsdl:portType>
   <wsdl:binding name="TSTWeatherSoapBinding" type="impl:TSTWeather">
      <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
      <wsdl:operation name="getAll">
         <wsdlsoap:operation soapAction=""/>
         <wsdl:input name="getAllRequest">
            <wsdlsoap:body use="literal"/>
         </wsdl:input>
         <wsdl:output name="getAllResponse">
            <wsdlsoap:body use="literal"/>
         </wsdl:output>
      </wsdl:operation>
   </wsdl:binding>
   <wsdl:service name="TSTWeatherService">
      <wsdl:port binding="impl:TSTWeatherSoapBinding" name="TSTWeather">
         <wsdlsoap:address location="http://localhost:8282/Services/service/TSTWeather"/>
      </wsdl:port>
   </wsdl:service>
</wsdl:definitions>

サービス応答の順序を指定する方法がわかりません。

4

2 に答える 2

1

多くの場合、WSDLを変更するだけではサービスは変更されず、XML内の要素の順序を決定するのはサービスです。

于 2009-08-18T16:30:54.260 に答える
1

特定のJavaファイルにJAXBアノテーションを追加することで、順序を変更できます。

例:@XmlType(propOrder = {"x"、 "y"、 "z"})

于 2016-05-27T11:19:20.247 に答える