Forum Discussion

alexisvasselon's avatar
12 years ago

How to get the response of the previous step

Hi,

I'm writing a little groovy script under SOAPUi to retrieve a value corresponding to a specific node in the Soap Response of my previous step in order to put it in the request of my next step.
The Soap response is structured like this :
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="http://twinsoft.com/convertigo/projects/BnppAltaresIdentite" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap-env:Header/>
<soap-env:Body soap-env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<getListeBilansResponse xmlns="http://identite.altares.ws.frontal.twinsoft.com" xmlns:ax218="http://request.callisto.newsys.altares.fr/xsd" xmlns:ax220="http://response.callisto.newsys.altares.fr/xsd" xmlns:ax221="http://vo.callisto.newsys.altares.fr/xsd" xmlns:ax223="http://finance.vo.callisto.newsys.altares.fr/xsd" xmlns:ax226="http://pcl.vo.callisto.newsys.altares.fr/xsd" xmlns:ax227="http://annonce.vo.callisto.newsys.altares.fr/xsd" xmlns:ax230="http://lien.vo.callisto.newsys.altares.fr/xsd" xmlns:ax233="http://identite.response.callisto.newsys.altares.fr/xsd">
<response>
<getListeBilansReturn>
<ax220:correct>true</ax220:correct>
<ax220:exception xsi:nil="true"/>
<ax220:parametres xsi:type="ax221:ParametreCallistoInfo">
<ax221:nbParametre>2</ax221:nbParametre>
<ax221:parametre xsi:type="ax221:ParametreCallisto">
<ax221:nom>refClient</ax221:nom>
<ax221:valeur>TestNRListeBilan</ax221:valeur>
</ax221:parametre>
<ax221:parametre xsi:type="ax221:ParametreCallisto">
<ax221:nom>siren</ax221:nom>
<ax221:valeur>015551096</ax221:valeur>
</ax221:parametre>
</ax220:parametres>
<ax220:myInfo xsi:type="ax221:ListeBilansInfo">
<ax221:bilanList xsi:type="ax223:DispoBilan">
<ax223:bilanId>8002748</ax223:bilanId>
<ax223:dateCloture>2012-03-31</ax223:dateCloture>
<ax223:duree>12</ax223:duree>
</ax221:bilanList>
<ax221:bilanList xsi:type="ax223:DispoBilan">
<ax223:bilanId>6938916</ax223:bilanId>
...
My groovy script contains the following instructions.
def project = testRunner.testCase.testSuite.project ;
def tcase = project.testSuites["Altares Identité TestSuite"].testCases["NR - Altares Identité"] ;
def tstep = tcase.getTestStepByName("getListeBilans");
def response_liste_bilans = tstep.getPropertyValue("response");

def gutils = new com.eviware.soapui.support.GroovyUtils(context);
def xml = gutils.getXmlHolder("getListeBilans#response");

I didn't managed to retrieve the first value of the node bilanId using the function getXmlHolder and the function getNodeValue.

Thanks a lot for your help.

Alexis