属性 在 SOAPUI 中传输。如何传输具有特定参数的数据?
Property Transfer in SOAPUI. How to transfer data with specific parameters?
我有这样的反应:
<s:Envelope xmlns:s="http://.....">
<s:Body>
<GetHistoricalMeterReadingsByEanResponse xmlns="....">
<GetHistoricalMeterReadingsByEanResult xmlns:a="....." xmlns:i="http://....">
<Header xmlns=".....">
<HasException>false</HasException>
<Message/>
</Header>
<a:HistoricalReadingSet>
<a:HistoricalMeterReadingSet>
<a:EanId>111425200000005564</a:EanId>
<a:HistoricalReadings>
<a:HistoricalMeterReading>
<a:ClientReadingDate i:nil="true"/>
<a:EanId>111425200000005564</a:EanId>
<a:EdsnMeterId>3523525</a:EdsnMeterId>
<a:EnergyProductType>ELK</a:EnergyProductType>
<a:MeterReadingId>1842643</a:MeterReadingId>
<a:Mutation>
<a:Consumer i:nil="true"/>
<a:DossierId i:nil="true"/>
<a:Initiator i:nil="true"/>
<a:MarketEvent>Historical</a:MarketEvent>
<a:MarketEventDate>2015-01-28T00:00:00</a:MarketEventDate>
</a:Mutation>
<a:NrOfRegisters>2</a:NrOfRegisters>
<a:ProcessId i:nil="true"/>
<a:ReadingSource>Customer_TMR</a:ReadingSource>
<a:RegisterReadings>
<a:RegisterReading>
<a:MeasureUnit>KWH</a:MeasureUnit>
<a:MeteringDirection>LVR</a:MeteringDirection>
<a:NrOfDigits>6</a:NrOfDigits>
<a:TariffType>L</a:TariffType>
<a:Value>1345</a:Value>
</a:RegisterReading>
<a:RegisterReading>
<a:MeasureUnit>KWH</a:MeasureUnit>
<a:MeteringDirection>LVR</a:MeteringDirection>
<a:NrOfDigits>6</a:NrOfDigits>
<a:TariffType>N</a:TariffType>
<a:Value>2345</a:Value>
</a:RegisterReading>
</a:RegisterReadings>
<a:Status>Accepted</a:Status>
<a:BudgetCanStartSettlement>false</a:BudgetCanStartSettlement>
<a:CanStartDispute>false</a:CanStartDispute>
<a:OtherSupplierCanStartSettlement>false</a:OtherSupplierCanStartSettlement>
</a:HistoricalMeterReading>
<a:HistoricalMeterReading>
<a:ClientReadingDate i:nil="true"/>
<a:EanId>111425200000005564</a:EanId>
<a:EdsnMeterId>3523525</a:EdsnMeterId>
<a:EnergyProductType>ELK</a:EnergyProductType>
<a:MeterReadingId>1842645</a:MeterReadingId>
<a:Mutation>
<a:Consumer>8714252018141</a:Consumer>
<a:DossierId>23074990</a:DossierId>
<a:Initiator>1114252018146</a:Initiator>
<a:MarketEvent>Periodic</a:MarketEvent>
<a:MarketEventDate>2015-09-14T00:00:00</a:MarketEventDate>
</a:Mutation>
<a:NrOfRegisters>2</a:NrOfRegisters>
<a:ProcessId i:nil="true"/>
<a:ReadingSource>Customer_EDSN</a:ReadingSource>
<a:RegisterReadings>
<a:RegisterReading>
<a:MeasureUnit>KWH</a:MeasureUnit>
<a:MeteringDirection>LVR</a:MeteringDirection>
<a:NrOfDigits>6</a:NrOfDigits>
<a:TariffType>L</a:TariffType>
<a:Value>3000</a:Value>
</a:RegisterReading>
<a:RegisterReading>
<a:MeasureUnit>KWH</a:MeasureUnit>
<a:MeteringDirection>LVR</a:MeteringDirection>
<a:NrOfDigits>6</a:NrOfDigits>
<a:TariffType>N</a:TariffType>
<a:Value>4000</a:Value>
</a:RegisterReading>
</a:RegisterReadings>
<a:Status>Accepted</a:Status>
<a:BudgetCanStartSettlement>false</a:BudgetCanStartSettlement>
<a:CanStartDispute>true</a:CanStartDispute>
<a:OtherSupplierCanStartSettlement>true</a:OtherSupplierCanStartSettlement>
</a:HistoricalMeterReading>
</a:HistoricalReadings>
</a:HistoricalMeterReadingSet>
</a:HistoricalReadingSet>
</GetHistoricalMeterReadingsByEanResult>
</GetHistoricalMeterReadingsByEanResponse>
问题是:我在 oreder 中使用这个响应来找到一个 3value 字段 = true 的项目。我需要这样的项目用于下一个请求方法。
我这样试过,但没有用:
<a:HistoricalReadingSet//a:HistoricalMeterReadingSet//a:HistoricalReadings//a:HistoricalMeterReading a="http://....">
{
for $x in //a:HistoricalReadingSet//a:HistoricalMeterReadingSet//a:HistoricalReadings//a:HistoricalMeterReading
where $x/a:HistoricalReadingSet//a:HistoricalMeterReadingSet//a:HistoricalReadings//a:HistoricalMeterReading//a:CanStartDispute/text() = 'true'
return $x
}
</a:HistoricalReadingSet//a:HistoricalMeterReadingSet//a:HistoricalReadings//a:HistoricalMeterReading>
怎么了?你会怎么做?
在 Xml 中,数字不允许作为标签名称的第一个字符,此外,您的 xml 格式不正确,因为某些标签未正确关闭。尝试先更正您的 xml.
<a:SetOfItems>
<a:Item>
<a:Id>1</a:Id>
<a:firstValue>12121212</a:firstValue>
<a:secondValue>sdfhjfsdf</a:secondValue>
<a:thirdValue>false</a:thirdValue>
</a:Item>
<a:Item>
<a:Id>2</a:Id>
<a:firstValue>12121212</a:firstValue>
<a:secondValue>sdfhjfsdf</a:secondValue>
<a:thirdValue>true</a:thirdValue>
</a:Item>
</a:SetOfItems>
然后将您的 XQuery 添加为 属性 传输到 select 只有 <a:Item>
元素,其中 <a:thirdValue>
具有文本值 true
您可以使用以下表达式:
<a:SetOfItems xmlns:a="blabla">
{
for $x in //*:Item
where $x/*:thirdValue/text() = 'true'
return $x
}
</a:SetOfItems>
注意使用 *
通配符来引用任何命名空间。
将此 XQuery 应用于您的 XML 您将获得:
<a:SetOfItems xmlns:a="blabla">
<a:Item>
<a:Id>2</a:Id>
<a:firstValue>12121212</a:firstValue>
<a:secondValue>sdfhjfsdf</a:secondValue>
<a:thirdValue>true</a:thirdValue>
</a:Item>
</a:SetOfItems>
根据问题更新进行编辑
我认为您的 XQuery 中存在各种问题,以下 XQuery 适用于您的 xml:
<a:HistoricalReadingSet xmlns:a="http://a">
{
for $x in //*:HistoricalReadingSet/*:HistoricalMeterReadingSet
where $x/*:HistoricalReadings/*:HistoricalMeterReading/*:CanStartDispute/text() = 'true'
return $x
}
</a:HistoricalReadingSet>
生成如下结果:
<a:HistoricalReadingSet xmlns:a="http://a">
<a:HistoricalMeterReadingSet xmlns:a="http://a" xmlns:i="http://i" xmlns="http://b" xmlns:s="http://soap">
<a:EanId>111425200000005564</a:EanId>
<a:HistoricalReadings>
<a:HistoricalMeterReading>
<a:ClientReadingDate i:nil="true"/>
<a:EanId>111425200000005564</a:EanId>
<a:EdsnMeterId>3523525</a:EdsnMeterId>
<a:EnergyProductType>ELK</a:EnergyProductType>
<a:MeterReadingId>1842643</a:MeterReadingId>
<a:Mutation>
<a:Consumer i:nil="true"/>
<a:DossierId i:nil="true"/>
<a:Initiator i:nil="true"/>
<a:MarketEvent>Historical</a:MarketEvent>
<a:MarketEventDate>2015-01-28T00:00:00</a:MarketEventDate>
</a:Mutation>
<a:NrOfRegisters>2</a:NrOfRegisters>
<a:ProcessId i:nil="true"/>
<a:ReadingSource>Customer_TMR</a:ReadingSource>
<a:RegisterReadings>
<a:RegisterReading>
<a:MeasureUnit>KWH</a:MeasureUnit>
<a:MeteringDirection>LVR</a:MeteringDirection>
<a:NrOfDigits>6</a:NrOfDigits>
<a:TariffType>L</a:TariffType>
<a:Value>1345</a:Value>
</a:RegisterReading>
<a:RegisterReading>
<a:MeasureUnit>KWH</a:MeasureUnit>
<a:MeteringDirection>LVR</a:MeteringDirection>
<a:NrOfDigits>6</a:NrOfDigits>
<a:TariffType>N</a:TariffType>
<a:Value>2345</a:Value>
</a:RegisterReading>
</a:RegisterReadings>
<a:Status>Accepted</a:Status>
<a:BudgetCanStartSettlement>false</a:BudgetCanStartSettlement>
<a:CanStartDispute>false</a:CanStartDispute>
<a:OtherSupplierCanStartSettlement>false</a:OtherSupplierCanStartSettlement>
</a:HistoricalMeterReading>
<a:HistoricalMeterReading>
<a:ClientReadingDate i:nil="true"/>
<a:EanId>111425200000005564</a:EanId>
<a:EdsnMeterId>3523525</a:EdsnMeterId>
<a:EnergyProductType>ELK</a:EnergyProductType>
<a:MeterReadingId>1842645</a:MeterReadingId>
<a:Mutation>
<a:Consumer>8714252018141</a:Consumer>
<a:DossierId>23074990</a:DossierId>
<a:Initiator>1114252018146</a:Initiator>
<a:MarketEvent>Periodic</a:MarketEvent>
<a:MarketEventDate>2015-09-14T00:00:00</a:MarketEventDate>
</a:Mutation>
<a:NrOfRegisters>2</a:NrOfRegisters>
<a:ProcessId i:nil="true"/>
<a:ReadingSource>Customer_EDSN</a:ReadingSource>
<a:RegisterReadings>
<a:RegisterReading>
<a:MeasureUnit>KWH</a:MeasureUnit>
<a:MeteringDirection>LVR</a:MeteringDirection>
<a:NrOfDigits>6</a:NrOfDigits>
<a:TariffType>L</a:TariffType>
<a:Value>3000</a:Value>
</a:RegisterReading>
<a:RegisterReading>
<a:MeasureUnit>KWH</a:MeasureUnit>
<a:MeteringDirection>LVR</a:MeteringDirection>
<a:NrOfDigits>6</a:NrOfDigits>
<a:TariffType>N</a:TariffType>
<a:Value>4000</a:Value>
</a:RegisterReading>
</a:RegisterReadings>
<a:Status>Accepted</a:Status>
<a:BudgetCanStartSettlement>false</a:BudgetCanStartSettlement>
<a:CanStartDispute>true</a:CanStartDispute>
<a:OtherSupplierCanStartSettlement>true</a:OtherSupplierCanStartSettlement>
</a:HistoricalMeterReading>
</a:HistoricalReadings>
</a:HistoricalMeterReadingSet>
</a:HistoricalReadingSet>
根据评论进行编辑
如果您只想获取 <MeterReadingId>
值,其中 <CanStartDispute>
sibling 为 true,您可以简单地使用以下 XPath 而不是 XQuery:
//*:HistoricalReadingSet/*:HistoricalMeterReadingSet/*:HistoricalReadings/*:HistoricalMeterReading/*:MeterReadingId[../*:CanStartDispute/text() = 'true']
希望对您有所帮助,
我有这样的反应:
<s:Envelope xmlns:s="http://.....">
<s:Body>
<GetHistoricalMeterReadingsByEanResponse xmlns="....">
<GetHistoricalMeterReadingsByEanResult xmlns:a="....." xmlns:i="http://....">
<Header xmlns=".....">
<HasException>false</HasException>
<Message/>
</Header>
<a:HistoricalReadingSet>
<a:HistoricalMeterReadingSet>
<a:EanId>111425200000005564</a:EanId>
<a:HistoricalReadings>
<a:HistoricalMeterReading>
<a:ClientReadingDate i:nil="true"/>
<a:EanId>111425200000005564</a:EanId>
<a:EdsnMeterId>3523525</a:EdsnMeterId>
<a:EnergyProductType>ELK</a:EnergyProductType>
<a:MeterReadingId>1842643</a:MeterReadingId>
<a:Mutation>
<a:Consumer i:nil="true"/>
<a:DossierId i:nil="true"/>
<a:Initiator i:nil="true"/>
<a:MarketEvent>Historical</a:MarketEvent>
<a:MarketEventDate>2015-01-28T00:00:00</a:MarketEventDate>
</a:Mutation>
<a:NrOfRegisters>2</a:NrOfRegisters>
<a:ProcessId i:nil="true"/>
<a:ReadingSource>Customer_TMR</a:ReadingSource>
<a:RegisterReadings>
<a:RegisterReading>
<a:MeasureUnit>KWH</a:MeasureUnit>
<a:MeteringDirection>LVR</a:MeteringDirection>
<a:NrOfDigits>6</a:NrOfDigits>
<a:TariffType>L</a:TariffType>
<a:Value>1345</a:Value>
</a:RegisterReading>
<a:RegisterReading>
<a:MeasureUnit>KWH</a:MeasureUnit>
<a:MeteringDirection>LVR</a:MeteringDirection>
<a:NrOfDigits>6</a:NrOfDigits>
<a:TariffType>N</a:TariffType>
<a:Value>2345</a:Value>
</a:RegisterReading>
</a:RegisterReadings>
<a:Status>Accepted</a:Status>
<a:BudgetCanStartSettlement>false</a:BudgetCanStartSettlement>
<a:CanStartDispute>false</a:CanStartDispute>
<a:OtherSupplierCanStartSettlement>false</a:OtherSupplierCanStartSettlement>
</a:HistoricalMeterReading>
<a:HistoricalMeterReading>
<a:ClientReadingDate i:nil="true"/>
<a:EanId>111425200000005564</a:EanId>
<a:EdsnMeterId>3523525</a:EdsnMeterId>
<a:EnergyProductType>ELK</a:EnergyProductType>
<a:MeterReadingId>1842645</a:MeterReadingId>
<a:Mutation>
<a:Consumer>8714252018141</a:Consumer>
<a:DossierId>23074990</a:DossierId>
<a:Initiator>1114252018146</a:Initiator>
<a:MarketEvent>Periodic</a:MarketEvent>
<a:MarketEventDate>2015-09-14T00:00:00</a:MarketEventDate>
</a:Mutation>
<a:NrOfRegisters>2</a:NrOfRegisters>
<a:ProcessId i:nil="true"/>
<a:ReadingSource>Customer_EDSN</a:ReadingSource>
<a:RegisterReadings>
<a:RegisterReading>
<a:MeasureUnit>KWH</a:MeasureUnit>
<a:MeteringDirection>LVR</a:MeteringDirection>
<a:NrOfDigits>6</a:NrOfDigits>
<a:TariffType>L</a:TariffType>
<a:Value>3000</a:Value>
</a:RegisterReading>
<a:RegisterReading>
<a:MeasureUnit>KWH</a:MeasureUnit>
<a:MeteringDirection>LVR</a:MeteringDirection>
<a:NrOfDigits>6</a:NrOfDigits>
<a:TariffType>N</a:TariffType>
<a:Value>4000</a:Value>
</a:RegisterReading>
</a:RegisterReadings>
<a:Status>Accepted</a:Status>
<a:BudgetCanStartSettlement>false</a:BudgetCanStartSettlement>
<a:CanStartDispute>true</a:CanStartDispute>
<a:OtherSupplierCanStartSettlement>true</a:OtherSupplierCanStartSettlement>
</a:HistoricalMeterReading>
</a:HistoricalReadings>
</a:HistoricalMeterReadingSet>
</a:HistoricalReadingSet>
</GetHistoricalMeterReadingsByEanResult>
</GetHistoricalMeterReadingsByEanResponse>
问题是:我在 oreder 中使用这个响应来找到一个 3value 字段 = true 的项目。我需要这样的项目用于下一个请求方法。
我这样试过,但没有用:
<a:HistoricalReadingSet//a:HistoricalMeterReadingSet//a:HistoricalReadings//a:HistoricalMeterReading a="http://....">
{
for $x in //a:HistoricalReadingSet//a:HistoricalMeterReadingSet//a:HistoricalReadings//a:HistoricalMeterReading
where $x/a:HistoricalReadingSet//a:HistoricalMeterReadingSet//a:HistoricalReadings//a:HistoricalMeterReading//a:CanStartDispute/text() = 'true'
return $x
}
</a:HistoricalReadingSet//a:HistoricalMeterReadingSet//a:HistoricalReadings//a:HistoricalMeterReading>
怎么了?你会怎么做?
在 Xml 中,数字不允许作为标签名称的第一个字符,此外,您的 xml 格式不正确,因为某些标签未正确关闭。尝试先更正您的 xml.
<a:SetOfItems>
<a:Item>
<a:Id>1</a:Id>
<a:firstValue>12121212</a:firstValue>
<a:secondValue>sdfhjfsdf</a:secondValue>
<a:thirdValue>false</a:thirdValue>
</a:Item>
<a:Item>
<a:Id>2</a:Id>
<a:firstValue>12121212</a:firstValue>
<a:secondValue>sdfhjfsdf</a:secondValue>
<a:thirdValue>true</a:thirdValue>
</a:Item>
</a:SetOfItems>
然后将您的 XQuery 添加为 属性 传输到 select 只有 <a:Item>
元素,其中 <a:thirdValue>
具有文本值 true
您可以使用以下表达式:
<a:SetOfItems xmlns:a="blabla">
{
for $x in //*:Item
where $x/*:thirdValue/text() = 'true'
return $x
}
</a:SetOfItems>
注意使用 *
通配符来引用任何命名空间。
将此 XQuery 应用于您的 XML 您将获得:
<a:SetOfItems xmlns:a="blabla">
<a:Item>
<a:Id>2</a:Id>
<a:firstValue>12121212</a:firstValue>
<a:secondValue>sdfhjfsdf</a:secondValue>
<a:thirdValue>true</a:thirdValue>
</a:Item>
</a:SetOfItems>
根据问题更新进行编辑
我认为您的 XQuery 中存在各种问题,以下 XQuery 适用于您的 xml:
<a:HistoricalReadingSet xmlns:a="http://a">
{
for $x in //*:HistoricalReadingSet/*:HistoricalMeterReadingSet
where $x/*:HistoricalReadings/*:HistoricalMeterReading/*:CanStartDispute/text() = 'true'
return $x
}
</a:HistoricalReadingSet>
生成如下结果:
<a:HistoricalReadingSet xmlns:a="http://a">
<a:HistoricalMeterReadingSet xmlns:a="http://a" xmlns:i="http://i" xmlns="http://b" xmlns:s="http://soap">
<a:EanId>111425200000005564</a:EanId>
<a:HistoricalReadings>
<a:HistoricalMeterReading>
<a:ClientReadingDate i:nil="true"/>
<a:EanId>111425200000005564</a:EanId>
<a:EdsnMeterId>3523525</a:EdsnMeterId>
<a:EnergyProductType>ELK</a:EnergyProductType>
<a:MeterReadingId>1842643</a:MeterReadingId>
<a:Mutation>
<a:Consumer i:nil="true"/>
<a:DossierId i:nil="true"/>
<a:Initiator i:nil="true"/>
<a:MarketEvent>Historical</a:MarketEvent>
<a:MarketEventDate>2015-01-28T00:00:00</a:MarketEventDate>
</a:Mutation>
<a:NrOfRegisters>2</a:NrOfRegisters>
<a:ProcessId i:nil="true"/>
<a:ReadingSource>Customer_TMR</a:ReadingSource>
<a:RegisterReadings>
<a:RegisterReading>
<a:MeasureUnit>KWH</a:MeasureUnit>
<a:MeteringDirection>LVR</a:MeteringDirection>
<a:NrOfDigits>6</a:NrOfDigits>
<a:TariffType>L</a:TariffType>
<a:Value>1345</a:Value>
</a:RegisterReading>
<a:RegisterReading>
<a:MeasureUnit>KWH</a:MeasureUnit>
<a:MeteringDirection>LVR</a:MeteringDirection>
<a:NrOfDigits>6</a:NrOfDigits>
<a:TariffType>N</a:TariffType>
<a:Value>2345</a:Value>
</a:RegisterReading>
</a:RegisterReadings>
<a:Status>Accepted</a:Status>
<a:BudgetCanStartSettlement>false</a:BudgetCanStartSettlement>
<a:CanStartDispute>false</a:CanStartDispute>
<a:OtherSupplierCanStartSettlement>false</a:OtherSupplierCanStartSettlement>
</a:HistoricalMeterReading>
<a:HistoricalMeterReading>
<a:ClientReadingDate i:nil="true"/>
<a:EanId>111425200000005564</a:EanId>
<a:EdsnMeterId>3523525</a:EdsnMeterId>
<a:EnergyProductType>ELK</a:EnergyProductType>
<a:MeterReadingId>1842645</a:MeterReadingId>
<a:Mutation>
<a:Consumer>8714252018141</a:Consumer>
<a:DossierId>23074990</a:DossierId>
<a:Initiator>1114252018146</a:Initiator>
<a:MarketEvent>Periodic</a:MarketEvent>
<a:MarketEventDate>2015-09-14T00:00:00</a:MarketEventDate>
</a:Mutation>
<a:NrOfRegisters>2</a:NrOfRegisters>
<a:ProcessId i:nil="true"/>
<a:ReadingSource>Customer_EDSN</a:ReadingSource>
<a:RegisterReadings>
<a:RegisterReading>
<a:MeasureUnit>KWH</a:MeasureUnit>
<a:MeteringDirection>LVR</a:MeteringDirection>
<a:NrOfDigits>6</a:NrOfDigits>
<a:TariffType>L</a:TariffType>
<a:Value>3000</a:Value>
</a:RegisterReading>
<a:RegisterReading>
<a:MeasureUnit>KWH</a:MeasureUnit>
<a:MeteringDirection>LVR</a:MeteringDirection>
<a:NrOfDigits>6</a:NrOfDigits>
<a:TariffType>N</a:TariffType>
<a:Value>4000</a:Value>
</a:RegisterReading>
</a:RegisterReadings>
<a:Status>Accepted</a:Status>
<a:BudgetCanStartSettlement>false</a:BudgetCanStartSettlement>
<a:CanStartDispute>true</a:CanStartDispute>
<a:OtherSupplierCanStartSettlement>true</a:OtherSupplierCanStartSettlement>
</a:HistoricalMeterReading>
</a:HistoricalReadings>
</a:HistoricalMeterReadingSet>
</a:HistoricalReadingSet>
根据评论进行编辑
如果您只想获取 <MeterReadingId>
值,其中 <CanStartDispute>
sibling 为 true,您可以简单地使用以下 XPath 而不是 XQuery:
//*:HistoricalReadingSet/*:HistoricalMeterReadingSet/*:HistoricalReadings/*:HistoricalMeterReading/*:MeterReadingId[../*:CanStartDispute/text() = 'true']
希望对您有所帮助,