Forum Discussion

Jasper175's avatar
Jasper175
Frequent Contributor
13 years ago

[Response] Find Value in XML Code Block

Hello Groovy Friends,

I need to figure out a better way to pull a value from within a code block. The script I use in Groovy is working...sort of. I won't paste that in, but here is an example of a return of Phone Numbers (did) a customer can have. The 'didType' which has many... the below has PHYS and TEMP.

I need to be able to extract a list of phoneNumbers (did) that has the didType == "PHYS"
Reason I need to do it through Groovy is because there are many DIDTYPES, there can be more than one etc...


   <SOAP-ENV:Body>
<ns2:GetServiceDidMapResponse xmlns:ns2="http://cleveland.vonage.com/services/servicelayer" xmlns:ns3="http://cleveland.vonage.com/services/servicelayer/internal" xmlns:ns4="http://cleveland.vonage.com/services/servicelayer/legacy">
<ns2:serviceEntities>
<ns2:networkId>128982952</ns2:networkId>
<ns2:didTargets>
<ns2:did>17325659833</ns2:did>
<ns2:didType>PHYS</ns2:didType>
<ns2:startDate>2012-10-16</ns2:startDate>
</ns2:didTargets>
<ns2:didTargets>
<ns2:did>17322025696</ns2:did>
<ns2:didType>TEMP</ns2:didType>
<ns2:startDate>2012-10-16</ns2:startDate>
</ns2:didTargets>
<ns2:startDate>2012-10-16</ns2:startDate>
</ns2:serviceEntities>
</ns2:GetServiceDidMapResponse>
</SOAP-ENV:Body>


Thank you,
Rob Long (Jasper175)

12 Replies

  • RJanecek's avatar
    RJanecek
    Regular Contributor
    hm I dont understand what you wanna to do. What you mean with "I need now to use that result in another API" and ${PHYS_DID#result} what is PHYS_DID and result ?

    when you wana use this property in another script you need to save

    context.setProperty("did", did)

    and then get

    context.getProperty("did")
  • Jasper175's avatar
    Jasper175
    Frequent Contributor
    The next API after the Groovy Script you gave is "searchResources" which I need the one of the MANY results it pours out.

    So if the context 'did' logs:
    null
    null
    null
    17322910001
    17322910002
    17322910003

    Ok - so while typing this I combined your knowledge w/ SoapUI conext...

    testRunner.testCase.testSuite.setPropertyValue( "did", did)

    This worked...
    Just wish I could interpret it all
    Thank you!