Forum Discussion

Oct21's avatar
Oct21
Occasional Contributor
6 years ago

Property transfer from response of one request to another request

Hi  Am new to Soap UI, Please help me in this. I have to transfer response value of my response XML to another request XML. Source response XML :  <ReceiptId idOwner="ABC"> <IdValue name="Re...
  • nmrao's avatar
    nmrao
    6 years ago

    Thank you Oct21  for the response.

     

    First <CDATA> part needs to be extracted and then extract the value that is needed.

     

    Use below Script Assertion for the first soap request itself and no extra groovy script required.

     

    /**
    * Script Assertion for the first request
    * Extracts the required id value
    * and saves at test case level custom properties
    * which can be used later steps
    * where required
    **/
    
    assert context.response
    
    def getData = { data, element ->
       new XmlSlurper().parseText(data).'**'.find {it.name() == element}
    }
    
    def inXmlStr = getData(context.response, 'TA_RegisterCandidateForAssessmentResult').text()
    
    def receiptId = getData(inXmlStr, 'ReceiptId')
    context.testCase.setPropertyValue('ID', receiptId.IdValue.toString())

    In the next request, use ${#TestCase#ID} where the value is needed.