cancel
Showing results for 
Search instead for 
Did you mean: 

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

Highlighted
New Contributor

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

9 REPLIES 9
Highlighted
Community Hero

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

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.


Regards,
Rao.
Highlighted
New Contributor

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

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>

Highlighted
Community Hero

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

@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?



Regards,
Rao.
Highlighted
Community Manager

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

Hi @satishdurugu, it looks like you replied to the email - this way your answer won't reach the Community. Please copy the answer here, thank you!


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Highlighted
New Contributor

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

Hi Rao,

 

I would like to capture the Request property in the groovy script and replace the DateofDeparture Element value with custom property value defined at Test Suite level and run the updated request.

 

Thanks,

Satish

Highlighted
Community Hero

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

Still unclear use case. Are you sending the same request two times with different dates like CREATE, UPDATE? or you want to send current date always?
You can use property expansion though if you have the value already in custom property. Please refer documentation
https://www.soapui.org/scripting-properties/property-expansion.html


Regards,
Rao.
Highlighted
New Contributor

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

Hi Rao,

I want to capture entire request into one variable , then access DepartureDateTime in the request with xpath and then replace it with new custom property value. Before doing that I would like to retrieve the value of the element using getNodeValue. But I am getting null value when I am trying to retrieve value of Departure Date Time element.

 

def saloffer = testRunner.testCase.testSteps["SAL_offer"].getPropertyValue("Request")
def salreqnode = new XmlHolder(saloffer);
def path = salreqnode.getNodeValue("//soapenv:Envelope/soapenv:Body//MerchOfferRequest/RequestCriterion/*:OriginDestinationOptions/*:FlightSegment/*:DepartureDateTime")
log.info path

 

Console output:

  • Sun Apr 19 01:57:29 CDT 2020:INFO:null
Highlighted
Community Hero

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

Can you please answer my previous question?



Regards,
Rao.
Highlighted
Community Hero

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

Here you go:

 

//Pass the xml as request variable
def departureDate = new XmlSlurper().parseText(request).'**'.find {it.name() == 'DepartureDateTime'}.text()
log.info departureDate

 You can test this online here https://www.ideone.com/ZJfPLa



Regards,
Rao.
New Here?
Join us and watch the welcome video:
Top Kudoed Authors