web services - SoapUI (Groovy) - passing a node value from a response to another request if a condition is true -



web services - SoapUI (Groovy) - passing a node value from a response to another request if a condition is true -

i appreciate help following:

xml response:

<soap-env:envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"> <soap-env:header/> <soap-env:body> <ns3:getseatplanavailabilityresponse xmlns:ns2="http://stagecoach.com/schemas/engine/common" xmlns:ns3="http://stagecoach.com/schemas/engine/seat"> <ns3:header> <ns2:version>1.0</ns2:version> </ns3:header> <ns3:journeydetails> <ns2:journeyid>4769046</ns2:journeyid> <ns2:origin> <ns2:cityid>120</ns2:cityid> <ns2:description>memphis, tn</ns2:description> <ns2:stop>mem</ns2:stop> </ns2:origin> <ns2:destination> <ns2:cityid>320</ns2:cityid> <ns2:description>austin, tx</ns2:description> <ns2:stop>aus</ns2:stop> </ns2:destination> <ns2:departuredate>2014-07-28z</ns2:departuredate> <ns2:departuretime>04:00:00z</ns2:departuretime> </ns3:journeydetails> <ns3:noofnonreservableseatsremaining>70</ns3:noofnonreservableseatsremaining> <ns3:singleseats> <ns2:singleseat> <ns2:seatplankey>us1</ns2:seatplankey> <ns2:seatid>7ecc7775-6caa-4e17-80d7-6cfa46be507b</ns2:seatid> <ns2:seatnumber>1</ns2:seatnumber> <ns2:seatclasscode>frn</ns2:seatclasscode> <ns2:seatdeck>upper</ns2:seatdeck> <ns2:availableforselection>true</ns2:availableforselection> </ns2:singleseat> <ns2:singleseat> <ns2:seatplankey>us2</ns2:seatplankey> <ns2:seatid>fe73cc9a-7c4f-4d1f-80e5-6131926af694</ns2:seatid> <ns2:seatnumber>2</ns2:seatnumber> <ns2:seatclasscode>frn</ns2:seatclasscode> <ns2:seatdeck>upper</ns2:seatdeck> <ns2:availableforselection>true</ns2:availableforselection> </ns2:singleseat> <ns2:singleseat> <ns2:seatplankey>us3</ns2:seatplankey> <ns2:seatid>20121517-d657-438f-bc26-92bb98b20bb5</ns2:seatid> <ns2:seatnumber>3</ns2:seatnumber> <ns2:seatclasscode>frn</ns2:seatclasscode> <ns2:seatdeck>upper</ns2:seatdeck> <ns2:availableforselection>true</ns2:availableforselection> </ns2:singleseat> <ns2:singleseat> <ns2:seatplankey>us4</ns2:seatplankey> <ns2:seatid>b93be6b7-ebb9-482e-9ec2-3c9d32beab32</ns2:seatid> <ns2:seatnumber>4</ns2:seatnumber> <ns2:seatclasscode>frn</ns2:seatclasscode> <ns2:seatdeck>upper</ns2:seatdeck> <ns2:availableforselection>true</ns2:availableforselection> </ns2:singleseat> </ns3:singleseats> <ns3:doubleseats/> <ns3:salesclassinformation> <ns2:seatclasscode>frn</ns2:seatclasscode> <ns2:salesclasscode>sfrn</ns2:salesclasscode> <ns2:salesclassdescription/> <ns2:price>3.00</ns2:price> <ns2:maxpassengers>1</ns2:maxpassengers> </ns3:salesclassinformation> <ns3:salesclassinformation> <ns2:seatclasscode>leg</ns2:seatclasscode> <ns2:salesclasscode>sleg</ns2:salesclasscode> <ns2:salesclassdescription/> <ns2:price>7.00</ns2:price> <ns2:maxpassengers>1</ns2:maxpassengers> </ns3:salesclassinformation> <ns3:salesclassinformation> <ns2:seatclasscode>tbl</ns2:seatclasscode> <ns2:salesclasscode>stbl</ns2:salesclasscode> <ns2:salesclassdescription/> <ns2:price>9.00</ns2:price> <ns2:maxpassengers>1</ns2:maxpassengers> </ns3:salesclassinformation> </ns3:getseatplanavailabilityresponse> </soap-env:body> </soap-env:envelope>

xml request:

<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bas="http://stagecoach.com/schemas/engine/basket" xmlns:com="http://stagecoach.com/schemas/engine/common"> <soapenv:header/> <soapenv:body> <bas:addseattobasketrequest> <bas:header> <com:version>1.0</com:version> <com:retailoperation>us</com:retailoperation> <com:channel>web</com:channel> </bas:header> <bas:basketitemid>56227</bas:basketitemid> <!--1 or more repetitions:--> <bas:seatselectioninput> <com:passengerordinal>1</com:passengerordinal> <com:seatid>7ecc7775-6caa-4e17-80d7-6cfa46be507b</com:seatid> </bas:seatselectioninput> <bas:seatselectioninput> <com:passengerordinal>2</com:passengerordinal> <com:seatid>d653b812-3230-4a31-88e7-a4ad867fb131</com:seatid> </bas:seatselectioninput> </bas:addseattobasketrequest> </soapenv:body> </soapenv:envelope>

my requirement such need pass <ns2:seatid> request, first should status when <ns2:availableforselection> true, or else should skip 'false' , select `and pass request

could 1 please provide groovy script above logic?

you need adjust below code exact needs, there still info missing in question.

// read node response def grutils = new com.eviware.soapui.support.groovyutils(context) // depending on when / how doing this, need provide exact test step name def xmlholder = grutils.getxmlholder("${context.currentstep.name}#response") def seatidnode = xmlholder.getdomnode("//*:singleseat[availableforselection='true']/seatid") // if nil found if(seatidnode == null) { testrunner.cancel("seatid not found!") homecoming } // can store in testcase property testrunner.testcase.setpropertyvalue("seatid", seatid.firstchild.nodevalue) // , utilize in next request '${#testcase#seatid}'

there way write seatid straight next request. if wish go route, have blog entry describes how generate xml requests.

lastly, of done pure soapui test steps, without utilize of groovy. conditional goto step check if xpath above exists, , bypass next request if not. transfer property step using same xpath above transfer value of seatid next request.

web-services groovy soapui

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -