Forum Discussion

dd's avatar
dd
Visitor
9 years ago
Solved

Extracting particular information from response

I am trying to fetch particular ID from soap response and I have pass that value to SQL query in the DataSource. Following is the soap response I am getting and I need to extract the text 'CDX14387' and pass it on to the SQL query. Can anyone please suggest a way to do this.

  • You may use the following code in the script assertion for the step.

     

    import com.eviware.soapui.support.XmlHolder

    def xml = new XmlHolder(context.response) def responseValue = xml.getNodeValue("//*:CDES-PUT-Response/*:response-message") def expectedPartialString = 'Job received successfully' def pattern = '[A-Z]+[0-9]+' if (responseValue.contains(expectedPartialString)) { def group = (responseValue =~ /${pattern}/)
    assert 1 == group.size(), "Received more than one CDE Job Id" context.testCase.setPropertyValue('JOB_ID',group[0]) } else { log.warning "Unexpected value in the response" }

    You should be able to use ${#TestCase#JOB_ID} in the next step i.e., in your jdbc request where that is needed

1 Reply

  • nmrao's avatar
    nmrao
    Champion Level 3

    You may use the following code in the script assertion for the step.

     

    import com.eviware.soapui.support.XmlHolder

    def xml = new XmlHolder(context.response) def responseValue = xml.getNodeValue("//*:CDES-PUT-Response/*:response-message") def expectedPartialString = 'Job received successfully' def pattern = '[A-Z]+[0-9]+' if (responseValue.contains(expectedPartialString)) { def group = (responseValue =~ /${pattern}/)
    assert 1 == group.size(), "Received more than one CDE Job Id" context.testCase.setPropertyValue('JOB_ID',group[0]) } else { log.warning "Unexpected value in the response" }

    You should be able to use ${#TestCase#JOB_ID} in the next step i.e., in your jdbc request where that is needed