Forum Discussion

rottier's avatar
rottier
New Contributor
12 years ago

help to define holder for response

Hello,
i'm working on SOAP-UI free 4.5.1
on my first try, i can define a holder to choose my reponse easily with this
WS sent :
<item1>value</item1> where from value i put "OK" or "Reject"
and in order to choose the mock response "Ok" or "Reject" by script
def item1 = holder["//cfn:item1"].toString()
if(item1 != "OK")
item1 = item1.substring(0,6)
return item1
But now, i have a new wsdl ans i didn't succeed to catch it
<cfn:item0>
<cfn:log item1="OK" item2="011410000"/>
</cfn:item0>
Please, could you help me to resolved it, i'd like to do the same test, only to change item1 value to change response (OK, Reject)
in advance , thanks for your reply
KR
Christian
  • rottier's avatar
    rottier
    New Contributor
    nmrao,
    Thanks for your reply
    but unfortunaltely, i don't succeed to catch substring <item1>
    KR
    Christian
  • nmrao's avatar
    nmrao
    Icon for Champion Level 2 rankChampion Level 2
    May be it would help to assist further if you can share more details.
  • rottier's avatar
    rottier
    New Contributor
    Hi,
    below my request is
    <soapenv:Envelope xmlns:cfn="namespace">
    <soapenv:Header>
    <cfn:contexteService>
    <cfn:agent item1="OK" item2="001"/>
    </cfn:contexteService>
    </soapenv:Header>
    <soapenv:Body>
    <cfn:ref1>
    <cfn:id>1234</cfn:id>
    </cfn:ref1>
    </soapenv:Body>
    </soapenv:Envelope>

    so, i don't succeed to catch the item1 (value = OK or Reject" (or item2) in soapenv header in order to select .
    if it could help
    KR
    Christian
  • nmrao's avatar
    nmrao
    Icon for Champion Level 2 rankChampion Level 2
    Assuming that the request step name is "test" and followed by a groovy script with following code


    def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
    holder = groovyUtils.getXmlHolder( "test#Request" )
    holder.namespaces["cfn"] = "namespace"
    def item1Value = holder.getNodeValue("//cfn:contexteService/cfn:agent/@item1")
    def item2Value = holder.getNodeValue("//cfn:contexteService/cfn:agent/@item2")
    log.info item1Value
    log.info item2Value
  • rottier's avatar
    rottier
    New Contributor
    Hi
    Thanks a lot, it works fine .
    i'm able now to keep specific tag value from soap header request .
    KR
    Christian