响应XML中的订单元素

时间:2013-07-15 10:42:38

标签: soap jax-ws java-metro-framework

我有一个SOAPAction,它返回一个包含位置的报告列表。职位应按特定顺序排列:按zOrder属性

排序

在发送回复之前,会对职位列表进行排序:

/*sort the positions in the report before adding it to the list*/
List<Position> orderedPositions = report.getPositions();
Collections.sort(orderedPositions, new Comparator<Position>() {
   @Override
   public int compare(Position position, Position position2) {
      return position.getZOrder().compareTo(position2.getZOrder());
   }
});
report.setPositions(orderedPositions);

我检查了列表的顺序是否正确,它是。

在响应XML中,<positions>标记的元素与java对象中的元素顺序不同。这些元素似乎根本没有订购。这是一段摘录:

<positions>
   <chapter>911</chapter>
   <chapterType>LPK</chapterType>
   <formId>16972704</formId>
   <materialNumber>121</materialNumber>
   <positionID>S16977468</positionID>
   <positionText>-</positionText>
   <positionType>Work</positionType>
   <quantity>9.0</quantity>
   <quantityUnit>h</quantityUnit>
   <serviceReport>16975051</serviceReport>
   <unitPrice>0.0</unitPrice>
   <xmlId>16977468</xmlId>
   <ZOrder>905</ZOrder>
</positions>
<positions>
   <chapter>0</chapter>
   <chapterType>LPK</chapterType>
   <formId>16972704</formId>
   <materialNumber></materialNumber>
   <positionID>S16977469</positionID>
   <positionText></positionText>
   <positionType>Material</positionType>
   <quantity>1.0</quantity>
   <quantityUnit>St</quantityUnit>
   <serviceReport>16975051</serviceReport>
   <unitPrice>0.0</unitPrice>
   <xmlId>16977469</xmlId>
   <ZOrder>1002</ZOrder>
</positions>
<positions>
   <chapter>0</chapter>
   <chapterType>NPK</chapterType>
   <formId>16972704</formId>
   <materialNumber></materialNumber>
   <positionID>S16977470</positionID>
   <positionText></positionText>
   <positionType>Material</positionType>
   <quantity>2.0</quantity>
   <quantityUnit>St</quantityUnit>
   <serviceReport>16975051</serviceReport>
   <unitPrice>0.0</unitPrice>
   <xmlId>16977470</xmlId>
   <ZOrder>1003</ZOrder>
</positions>
<positions>
   <chapter>0</chapter>
   <chapterType>LPK</chapterType>
   <formId>16972704</formId>
   <materialNumber></materialNumber>
   <positionID>S16977471</positionID>
   <positionText></positionText>
   <positionType>Material</positionType>
   <quantity>3.0</quantity>
   <quantityUnit>St</quantityUnit>
   <serviceReport>16975051</serviceReport>
   <unitPrice>0.0</unitPrice>
   <xmlId>16977471</xmlId>
   <ZOrder>1004</ZOrder>
</positions>

如何将响应XML中的positions元素按其ZOrder属性排序?

0 个答案:

没有答案