Forum Discussion

dinojadhav's avatar
dinojadhav
Occasional Contributor
5 years ago

How to get all the values from a duplicate tag and set the same in properties using groovy

Hello All,

 

I have below XML response and want to capture all the values coming in a "FullText" tag.<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Header>
<eb:MessageHeader eb:version="1.0" soap-env:mustUnderstand="1" xmlns:eb="http://www.ebxml.org/namespaces/messageHeader">
<eb:From>
<eb:PartyId eb:type="URI">123123</eb:PartyId>
</eb:From>
<eb:To>
<eb:PartyId eb:type="URI">99999</eb:PartyId>
</eb:To>
<eb:CPAId>AAS</eb:CPAId>
<eb:ConversationId>test</eb:ConversationId>
<eb:Service eb:type="OTA">CDI</eb:Service>
<eb:Action>getReservationRS</eb:Action>
<eb:MessageData>
<eb:MessageId>732934421208470870</eb:MessageId>
<eb:Timestamp>2019-10-30T11:42:01</eb:Timestamp>
<eb:RefToMessageId>mid:20001209-133003-2333@clientofsabre.com</eb:RefToMessageId>
</eb:MessageData>
</eb:MessageHeader>
<wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext">
<wsse:BinarySecurityToken valueType="String" EncodingType="wsse:Base64Binary">Shared/IDL:IceSess\/SessMgr:1\.0.IDL/Common/!ICESMS\/STSB!ICESMSLB\/STS.LB!-2958029294769305206!947761!0</wsse:BinarySecurityToken>
</wsse:Security>
</soap-env:Header>
<soap-env:Body>
<stl19:GetReservationRS Version="1.19.0" xmlns:stl19="http://webservices.sabre.com/pnrbuilder/v1_19" xmlns:ns6="http://services.sabre.com/res/orr/v0" xmlns:or114="http://services.sabre.com/res/or/v1_14" xmlns:raw="http://tds.sabre.com/itinerary" xmlns:ns4="http://webservices.sabre.com/pnrconn/ReaccSearch">
<stl19:Reservation numberInParty="2" numberOfInfants="0" NumberInSegment="2" hostMarketedCodeShare="true">
<stl19:BookingDetails>
<stl19:RecordLocator>IVUTDX</stl19:RecordLocator>
<stl19:CreationTimestamp>2019-10-30T06:41:00</stl19:CreationTimestamp>
<stl19:SystemCreationTimestamp>2019-10-30T06:41:00</stl19:SystemCreationTimestamp>
<stl19:CreationAgentID>DJL</stl19:CreationAgentID>
<stl19:UpdateTimestamp>2019-10-30T06:41:59</stl19:UpdateTimestamp>
<stl19:PNRSequence>2</stl19:PNRSequence>
<stl19:FlightsRange Start="2019-11-20T20:50:00" End="2019-11-23T04:50:00"/>
<stl19:DivideSplitDetails/>
<stl19:EstimatedPurgeTimestamp>2019-11-22T00:00:00</stl19:EstimatedPurgeTimestamp>
<stl19:UpdateToken>-40f1ee0d3c43ffa7e317052347c74ab6f00fc159d2c3a361</stl19:UpdateToken>
</stl19:BookingDetails>
<stl19:POS AirExtras="false" InhibitCode="U">
<stl19:Source BookingSource="GH35" AgentSine="DJL" PseudoCityCode="GH35" ISOCountry="DE" AgentDutyCode="*" AirlineVendorID="AA" HomePseudoCityCode="HDQ" PrimeHostID="1S"/>
</stl19:POS>
<stl19:PassengerReservation>
<stl19:Passengers>
<stl19:Passenger id="20" nameType="S" passengerType="ADT" nameId="01.01" nameAssocId="1" elementId="pnr-20.1">
<stl19:LastName>ZEEYEVU</stl19:LastName>
<stl19:FirstName>TYFEXH</stl19:FirstName>
<stl19:SpecialRequests>
<stl19:GenericSpecialRequest id="25" type="A" msgType="S">
<stl19:Code>GSTN</stl19:Code>
<stl19:FreeText>/IND/22WWWWWWWW0A1Z5/IBM/P</stl19:FreeText>
<stl19:ActionCode>HK</stl19:ActionCode>
<stl19:NumberInParty>1</stl19:NumberInParty>
<stl19:AirlineCode>AA</stl19:AirlineCode>
<stl19:FullText>GSTN AA HK1/IND/22WWWWWWWW0A1Z5/IBM/P</stl19:FullText>
</stl19:GenericSpecialRequest>
<stl19:GenericSpecialRequest id="26" type="A" msgType="S">
<stl19:Code>GSTN</stl19:Code>
<stl19:FreeText>/IND/22DDDWWWWW0A2S5/IBM/U</stl19:FreeText>
<stl19:ActionCode>HK</stl19:ActionCode>
<stl19:NumberInParty>1</stl19:NumberInParty>
<stl19:AirlineCode>AA</stl19:AirlineCode>
<stl19:FullText>GSTN AA HK1/IND/22DDDWWWWW0A2S5/IBM/U</stl19:FullText>
</stl19:GenericSpecialRequest>
</stl19:SpecialRequests>
<stl19:Seats/>
</stl19:Passenger>
<stl19:Passenger id="22" nameType="S" passengerType="ADT" nameId="02.01" nameAssocId="2" elementId="pnr-22.2">
<stl19:LastName>NHFKDBG</stl19:LastName>
<stl19:FirstName>SVHJIT</stl19:FirstName>
<stl19:SpecialRequests>
<stl19:GenericSpecialRequest id="27" type="A" msgType="S">
<stl19:Code>GSTN</stl19:Code>
<stl19:FreeText>/IND/22SSSSAAA00A1Z5/IBM/S</stl19:FreeText>
<stl19:ActionCode>HK</stl19:ActionCode>
<stl19:NumberInParty>1</stl19:NumberInParty>
<stl19:AirlineCode>AA</stl19:AirlineCode>
<stl19:FullText>GSTN AA HK1/IND/22SSSSAAA00A1Z5/IBM/S</stl19:FullText>
</stl19:GenericSpecialRequest>
<stl19:GenericSpecialRequest id="28" type="A" msgType="S">
<stl19:Code>GSTN</stl19:Code>
<stl19:FreeText>/IND/22DDDDDDDDDD1Z5/IBM/P</stl19:FreeText>
<stl19:ActionCode>HK</stl19:ActionCode>
<stl19:NumberInParty>1</stl19:NumberInParty>
<stl19:AirlineCode>AA</stl19:AirlineCode>
<stl19:FullText>GSTN AA HK1/IND/22DDDDDDDDDD1Z5/IBM/P</stl19:FullText>
</stl19:GenericSpecialRequest>
</stl19:SpecialRequests>
<stl19:Seats/>
</stl19:Passenger>
</stl19:Passengers>
<stl19:Segments>
<stl19:Poc>
<stl19:Airport>EZE</stl19:Airport>
<stl19:Departure>2019-11-20T20:50:00</stl19:Departure>
</stl19:Poc>
<stl19:Segment sequence="1" id="3">
<stl19:Air id="3" sequence="1" segmentAssociationId="2" isPast="false" DayOfWeekInd="3" CodeShare="false" SpecialMeal="false" SmokingAllowed="false" ResBookDesigCode="Y">
<stl19:DepartureAirport>EZE</stl19:DepartureAirport>
<stl19:DepartureAirportCodeContext>IATA</stl19:DepartureAirportCodeContext>
<stl19:ArrivalAirport>MIA</stl19:ArrivalAirport>
<stl19:ArrivalAirportCodeContext>IATA</stl19:ArrivalAirportCodeContext>
<stl19:OperatingAirlineCode>AA</stl19:OperatingAirlineCode>
<stl19:OperatingAirlineShortName>AMERICAN AIRLINES</stl19:OperatingAirlineShortName>
<stl19:OperatingFlightNumber>0900</stl19:OperatingFlightNumber>
<stl19:EquipmentType>77W</stl19:EquipmentType>
<stl19:MarketingAirlineCode>AA</stl19:MarketingAirlineCode>
<stl19:MarketingFlightNumber>0900</stl19:MarketingFlightNumber>
<stl19:OperatingClassOfService>Y</stl19:OperatingClassOfService>
<stl19:MarketingClassOfService>Y</stl19:MarketingClassOfService>
<stl19:MarriageGrp>
<stl19:Ind>0</stl19:Ind>
<stl19:Group>0</stl19:Group>
<stl19:Sequence>0</stl19:Sequence>
</stl19:MarriageGrp>
<stl19:Seats/>
<stl19:AirlineRefId>DCAA*IVUTDX</stl19:AirlineRefId>
<stl19:Eticket>true</stl19:Eticket>
<stl19:DepartureDateTime>2019-11-20T20:50:00</stl19:DepartureDateTime>
<stl19:ArrivalDateTime>2019-11-21T04:10:00</stl19:ArrivalDateTime>
<stl19:FlightNumber>0900</stl19:FlightNumber>
<stl19:ClassOfService>Y</stl19:ClassOfService>
<stl19:ActionCode>HK</stl19:ActionCode>
<stl19:NumberInParty>2</stl19:NumberInParty>
<stl19:SegmentSpecialRequests/>
<stl19:inboundConnection>false</stl19:inboundConnection>
<stl19:outboundConnection>false</stl19:outboundConnection>
<stl19:ScheduleChangeIndicator>false</stl19:ScheduleChangeIndicator>
<stl19:SegmentBookedDate>2019-10-30T06:41:00</stl19:SegmentBookedDate>
<stl19:Pos>
<stl19:IataNumber>2323972</stl19:IataNumber>
<stl19:AgencyCityCode>STR</stl19:AgencyCityCode>
<stl19:CountryCode>DE</stl19:CountryCode>
<stl19:DutyCode>*</stl19:DutyCode>
</stl19:Pos>
<stl19:Banner>MARKETED BY AMERICAN AIRLINES</stl19:Banner>
<stl19:Informational>false</stl19:Informational>
</stl19:Air>
</stl19:Segment>
<stl19:Segment sequence="2" id="9">
<stl19:Air id="9" sequence="2" segmentAssociationId="3" isPast="false" DayOfWeekInd="4" CodeShare="false" SpecialMeal="false" SmokingAllowed="false" ResBookDesigCode="Y">
<stl19:DepartureAirport>MIA</stl19:DepartureAirport>
<stl19:DepartureAirportCodeContext>IATA</stl19:DepartureAirportCodeContext>
<stl19:ArrivalAirport>EZE</stl19:ArrivalAirport>
<stl19:ArrivalAirportCodeContext>IATA</stl19:ArrivalAirportCodeContext>
<stl19:OperatingAirlineCode>AA</stl19:OperatingAirlineCode>
<stl19:OperatingAirlineShortName>AMERICAN AIRLINES</stl19:OperatingAirlineShortName>
<stl19:OperatingFlightNumber>0907</stl19:OperatingFlightNumber>
<stl19:EquipmentType>772</stl19:EquipmentType>
<stl19:MarketingAirlineCode>AA</stl19:MarketingAirlineCode>
<stl19:MarketingFlightNumber>0907</stl19:MarketingFlightNumber>
<stl19:OperatingClassOfService>Y</stl19:OperatingClassOfService>
<stl19:MarketingClassOfService>Y</stl19:MarketingClassOfService>
<stl19:MarriageGrp>
<stl19:Ind>0</stl19:Ind>
<stl19:Group>0</stl19:Group>
<stl19:Sequence>0</stl19:Sequence>
</stl19:MarriageGrp>
<stl19:Seats/>
<stl19:AirlineRefId>DCAA*IVUTDX</stl19:AirlineRefId>
<stl19:Eticket>true</stl19:Eticket>
<stl19:DepartureDateTime>2019-11-21T20:00:00</stl19:DepartureDateTime>
<stl19:ArrivalDateTime>2019-11-22T07:07:00</stl19:ArrivalDateTime>
<stl19:FlightNumber>0907</stl19:FlightNumber>
<stl19:ClassOfService>Y</stl19:ClassOfService>
<stl19:ActionCode>HK</stl19:ActionCode>
<stl19:NumberInParty>2</stl19:NumberInParty>
<stl19:SegmentSpecialRequests/>
<stl19:inboundConnection>false</stl19:inboundConnection>
<stl19:outboundConnection>false</stl19:outboundConnection>
<stl19:ScheduleChangeIndicator>false</stl19:ScheduleChangeIndicator>
<stl19:SegmentBookedDate>2019-10-30T06:41:00</stl19:SegmentBookedDate>
<stl19:Pos>
<stl19:IataNumber>2323972</stl19:IataNumber>
<stl19:AgencyCityCode>STR</stl19:AgencyCityCode>
<stl19:CountryCode>DE</stl19:CountryCode>
<stl19:DutyCode>*</stl19:DutyCode>
</stl19:Pos>
<stl19:Banner>MARKETED BY AMERICAN AIRLINES</stl19:Banner>
<stl19:Informational>false</stl19:Informational>
</stl19:Air>
</stl19:Segment>
<stl19:Segment sequence="3" id="15">
<stl19:Air id="15" sequence="3" segmentAssociationId="4" isPast="false" DayOfWeekInd="5" CodeShare="false" SpecialMeal="false" SmokingAllowed="false" ResBookDesigCode="Y">
<stl19:DepartureAirport>EZE</stl19:DepartureAirport>
<stl19:DepartureAirportCodeContext>IATA</stl19:DepartureAirportCodeContext>
<stl19:ArrivalAirport>MIA</stl19:ArrivalAirport>
<stl19:ArrivalAirportCodeContext>IATA</stl19:ArrivalAirportCodeContext>
<stl19:OperatingAirlineCode>4M</stl19:OperatingAirlineCode>
<stl19:OperatingAirlineShortName>LATAM AIRLINES ARGENTINA</stl19:OperatingAirlineShortName>
<stl19:OperatingFlightNumber>7820</stl19:OperatingFlightNumber>
<stl19:EquipmentType>763</stl19:EquipmentType>
<stl19:MarketingAirlineCode>AA</stl19:MarketingAirlineCode>
<stl19:MarketingFlightNumber>7836</stl19:MarketingFlightNumber>
<stl19:OperatingClassOfService>Y</stl19:OperatingClassOfService>
<stl19:MarketingClassOfService>Y</stl19:MarketingClassOfService>
<stl19:CodeShareOperatingRecordLocator>IVUTMY</stl19:CodeShareOperatingRecordLocator>
<stl19:MarriageGrp>
<stl19:Ind>0</stl19:Ind>
<stl19:Group>0</stl19:Group>
<stl19:Sequence>0</stl19:Sequence>
</stl19:MarriageGrp>
<stl19:Seats/>
<stl19:AirlineRefId>DCAA*IVUTDX</stl19:AirlineRefId>
<stl19:Eticket>true</stl19:Eticket>
<stl19:DepartureDateTime>2019-11-22T21:35:00</stl19:DepartureDateTime>
<stl19:ArrivalDateTime>2019-11-23T04:50:00</stl19:ArrivalDateTime>
<stl19:FlightNumber>7836</stl19:FlightNumber>
<stl19:ClassOfService>Y</stl19:ClassOfService>
<stl19:ActionCode>HK</stl19:ActionCode>
<stl19:NumberInParty>2</stl19:NumberInParty>
<stl19:SegmentSpecialRequests/>
<stl19:inboundConnection>false</stl19:inboundConnection>
<stl19:outboundConnection>false</stl19:outboundConnection>
<stl19:ScheduleChangeIndicator>false</stl19:ScheduleChangeIndicator>
<stl19:SegmentBookedDate>2019-10-30T06:41:00</stl19:SegmentBookedDate>
<stl19:Pos>
<stl19:IataNumber>2323972</stl19:IataNumber>
<stl19:AgencyCityCode>STR</stl19:AgencyCityCode>
<stl19:CountryCode>DE</stl19:CountryCode>
<stl19:DutyCode>*</stl19:DutyCode>
</stl19:Pos>
<stl19:Banner>MARKETED BY AMERICAN AIRLINES</stl19:Banner>
<stl19:Informational>false</stl19:Informational>
</stl19:Air>
</stl19:Segment>
</stl19:Segments>
<stl19:TicketingInfo>
<stl19:TicketingTimeLimit id="29" index="1" elementId="pnr-29">
<stl19:Time>TL30</stl19:Time>
</stl19:TicketingTimeLimit>
</stl19:TicketingInfo>
<stl19:ItineraryPricing/>
</stl19:PassengerReservation>
<stl19:ReceivedFrom>
<stl19:Name>QA</stl19:Name>
</stl19:ReceivedFrom>
<stl19:PhoneNumbers>
<stl19:PhoneNumber id="24" index="1" elementId="pnr-24">
<stl19:CityCode>STR</stl19:CityCode>
<stl19:Number>594999</stl19:Number>
</stl19:PhoneNumber>
</stl19:PhoneNumbers>
<stl19:EmailAddresses/>
<stl19:OpenReservationElements>
<or114:OpenReservationElement id="25" type="SRVC" elementId="pnr-25">
<or114:ServiceRequest actionCode="HK" airlineCode="AA" code="GSTN" serviceCount="1" serviceType="SSR" ssrType="AFX">
<or114:FreeText>/IND/22WWWWWWWW0A1Z5/IBM/P</or114:FreeText>
<or114:FullText>GSTN AA HK1/IND/22WWWWWWWW0A1Z5/IBM/P</or114:FullText>
</or114:ServiceRequest>
<or114:NameAssociation>
<or114:LastName>ZEEYEVU</or114:LastName>
<or114:FirstName>TYFEXH</or114:FirstName>
<or114:NameRefNumber>01.01</or114:NameRefNumber>
</or114:NameAssociation>
</or114:OpenReservationElement>
<or114:OpenReservationElement id="26" type="SRVC" elementId="pnr-26">
<or114:ServiceRequest actionCode="HK" airlineCode="AA" code="GSTN" serviceCount="1" serviceType="SSR" ssrType="AFX">
<or114:FreeText>/IND/22DDDWWWWW0A2S5/IBM/U</or114:FreeText>
<or114:FullText>GSTN AA HK1/IND/22DDDWWWWW0A2S5/IBM/U</or114:FullText>
</or114:ServiceRequest>
<or114:NameAssociation>
<or114:LastName>ZEEYEVU</or114:LastName>
<or114:FirstName>TYFEXH</or114:FirstName>
<or114:NameRefNumber>01.01</or114:NameRefNumber>
</or114:NameAssociation>
</or114:OpenReservationElement>
<or114:OpenReservationElement id="27" type="SRVC" elementId="pnr-27">
<or114:ServiceRequest actionCode="HK" airlineCode="AA" code="GSTN" serviceCount="1" serviceType="SSR" ssrType="AFX">
<or114:FreeText>/IND/22SSSSAAA00A1Z5/IBM/S</or114:FreeText>
<or114:FullText>GSTN AA HK1/IND/22SSSSAAA00A1Z5/IBM/S</or114:FullText>
</or114:ServiceRequest>
<or114:NameAssociation>
<or114:LastName>NHFKDBG</or114:LastName>
<or114:FirstName>SVHJIT</or114:FirstName>
<or114:NameRefNumber>02.01</or114:NameRefNumber>
</or114:NameAssociation>
</or114:OpenReservationElement>
<or114:OpenReservationElement id="28" type="SRVC" elementId="pnr-28">
<or114:ServiceRequest actionCode="HK" airlineCode="AA" code="GSTN" serviceCount="1" serviceType="SSR" ssrType="AFX">
<or114:FreeText>/IND/22DDDDDDDDDD1Z5/IBM/P</or114:FreeText>
<or114:FullText>GSTN AA HK1/IND/22DDDDDDDDDD1Z5/IBM/P</or114:FullText>
</or114:ServiceRequest>
<or114:NameAssociation>
<or114:LastName>NHFKDBG</or114:LastName>
<or114:FirstName>SVHJIT</or114:FirstName>
<or114:NameRefNumber>02.01</or114:NameRefNumber>
</or114:NameAssociation>
</or114:OpenReservationElement>
</stl19:OpenReservationElements>
</stl19:Reservation>
</stl19:GetReservationRS>
</soap-env:Body>
</soap-env:Envelope>

 

I have used below groovy script and able to print all the values but unable to set the same in property. I want each value to be set in property :

 

import com.eviware.soapui.support.GroovyUtils
import com.eviware.soapui.support.XmlHolder

def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def xmlHolder = groovyUtils.getXmlHolder("GetReservation#Response")

def val = xmlHolder["//*:FullText"]
def count = xmlHolder["count(//*:FullText)"]
def SsrFullText="";
log.info count
for(i=1;i<count.toInteger();i++){
//log.info val[i] // it will print all the values from duplicate SSR Text
SsrFullText=val[i];
log.info SsrFullText
context.testCase.testSuite.setPropertyValue('SsrFullText',SsrFullText)


}

 

 

2 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    What would you like to do after collecting the values?
    Properties can only hold String key value pairs.
    You are facing problem as you are trying to store the list.
    • dinojadhav's avatar
      dinojadhav
      Occasional Contributor

      I will store those values and then assert them with the values coming in other responses.

      Is there a way to fetch values from the list.