Forum Discussion

satishdurugu's avatar
satishdurugu
New Contributor
5 years ago

Not able get the Node value and seeing [Ljava.lang.String;@36013a3b error in Grooy script response

Hi I am trying to implement Groovy Srcipt for below request to retrive the Node value of the 3rd element in SOAP request using getNodeValue or getNodeValues method by accessing the xpath of the element but I am seeing below message in log. Please help me how to retrieve the actual value of DepartureDateTime element in the below request. 

 

Groovry Script Response: Fri Apr 03 16:14:15 CDT 2020:INFO:[Ljava.lang.String;@36013a3b.

 

I have added Custom Properties TrvlDateTime,TrvlDateArv and Tktdate at Test Suite Level and would like

 

My Sample SOAP XML Request :

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://www.del.com/merch/services">
<soapenv:Header/>
<soapenv:Body>
<MerchOfferRequest TransactionIdentifier="55678" TransactionLog="true">
<RequestCriterion>
<OriginDestinationOptions Id="OD1">
<FlightSegment ActiveInd="Y" Id="1">
<DepartureAirport LocationCode="IAH"/>
<ArrivalAirport LocationCode="DEN"/>
<DepartureDateTime>2020-12-01T19:00:00</DepartureDateTime>
<ArrivalDateTime>2020-12-01T19:00:00</ArrivalDateTime>
<FlightNumber>863</FlightNumber>
</MerchOfferRequest>
</soapenv:Body>
</soapenv:Envelope>

 

My Groovy Script Code:

def tdep = testRunner.testCase.testSuite.getPropertyValue("TrvlDateTime")
def tarv = testRunner.testCase.testSuite.getPropertyValue("TrvlDateArv")
def ttkt = testRunner.testCase.testSuite.getPropertyValue("Tktdate")
def saloffer = testRunner.testCase.testSteps["SAL_offer"].getPropertyValue("Request")
def salreqnode = new XmlHolder(saloffer);
def path = salreqnode.getNodeValues('//soapenv:Envelope/soapenv:Body/MerchOfferRequest/RequestCriterion/OriginDestinationOptions/FlightSegment/DepartureDateTime')
log.info path

  • nmrao's avatar
    nmrao
    Champion Level 3
    Is that complete request? please provide valid request (with dummy data is fine), but same structure. I guess, there are more than one child nodes.
    Solution will dependent on that.
    • satishdurugu's avatar
      satishdurugu
      New Contributor

      Hi NMRao,

       

      Here is full request. I would like to take control of whole request into groovy script and replace some element values with Custom Properties defined at Test Suite level. When I am executing the groovy script now its returning null value. I have attached my groovy script.

       

      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://www.united.com/merch/services">
      <soapenv:Header/>
      <soapenv:Body>
      <MerchOfferRequest TransactionIdentifier="55678" TransactionLog="true">
      <RequestCriterion>
      <OriginDestinationOptions Id="OD1">
      <FlightSegment ActiveInd="Y" Id="1">
      <DepartureAirport LocationCode="IAH"/>
      <ArrivalAirport LocationCode="DEN"/>
      <DepartureDateTime>dfdf</DepartureDateTime>
      <ArrivalDateTime>2020-12-01T19:00:00</ArrivalDateTime>
      <FlightNumber>863</FlightNumber>
      <OperatingAirline>UA</OperatingAirline>
      <MarketingAirline>UA</MarketingAirline>
      <SegmentNumber>1</SegmentNumber>
      <ClassOfService>Y</ClassOfService>
      <TripIndicator>C</TripIndicator>
      <SegmentStatus>HK</SegmentStatus>
      <IsSeatMapPricing>false</IsSeatMapPricing>
      </FlightSegment>
      </OriginDestinationOptions>
      <TravelerInfo>
      <Traveler HostIndex="1.1">
      <Id>1</Id>
      <GivenName>THREESILVER</GivenName>
      <Surname>TESTER</Surname>
      <PassengerTypeCode>ADT</PassengerTypeCode>
      <!--<TravelerCategory>MET</TravelerCategory>-->
      <Gender>Unknown</Gender>
      <TicketingDate>2020-03-25T00:00:00</TicketingDate>
      <TicketNumber/>
      </Traveler>
      </TravelerInfo>
      <IncludeExcludeOffers>
      <ServiceFilterCode ServiceCode="BAG" ResultAction="Include"/>
      </IncludeExcludeOffers>
      <!--<BookingReferenceIds BookingReferenceId="CDBZ7L"/>-->
      </RequestCriterion>
      <Requestor ChannelId="101" CurrencyCode="" ChannelName="OBE" CountryCode="US" TicketingCountryCode="US"/>
      </MerchOfferRequest>
      </soapenv:Body>
      </soapenv:Envelope>

      • nmrao's avatar
        nmrao
        Champion Level 3

        satishdurugu 

        Thanks for adding request.

         

        However, not sure what you mean by "take control of whole request into groovy script"?

         

        The question is not clear whether you want to retrieve data or youo want to replace the data.

        Also do specify which fields (or data) that needs to be worked on.

        Or please give high level view of your use case or what you are trying to achieve?