Forum Discussion

mvsrikanthvarma's avatar
mvsrikanthvarma
New Contributor
13 years ago

Need help on Script Assertion

I need help on Script Assertion in SOAP UI.

Below is Script Assertion and webservice response i got (which is an error response). I wanted to add a Script Assertion to handle this error response.

The below script is not working for me. Please help on this.

Script I have added :

import com.eviware.soapui.support.XmlHolder

def holder = new XmlHolder( messageExchange.responseContentAsXml )

holder.namespaces["ns1"] = "http://abcd.com/types/common"

def node = holder.getDomNode( "//ns1:messageList[1]/message[1]/type" )

assert node.nodeValue != 'BUSINESS_LOGIC_ERROR'



<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsu:Timestamp wsu:Id="Timestamp-1482774625" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsu:Created>2011-07-04T10:25:30.269Z</wsu:Created>
<wsu:Expires>2011-07-04T10:30:30.269Z</wsu:Expires>
</wsu:Timestamp>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<EbMtvnSvcRes xmlns="http://efgh.abcd.com/types/response">
<AbcdSvcVer>v1.4.0</AbcdSvcVer>
<MsgUUID>5757y4575re756</MsgUUID>
<Svc>
<SvcParms>
<ApplID>EB</ApplID>
<SvcID>AddConsumer</SvcID>
<SvcVer>v1.4.0</SvcVer>
<RqstUUID>q3423r534634</RqstUUID>
</SvcParms>
<MsgData>
<AddConsumer>
<ns1:messageList xmlns:ns1="http://abcd.com/types/common">
<ns1:message>
<ns1:source/>
<ns1:type>BUSINESS_LOGIC_ERROR</ns1:type>
<ns1:code>CON073</ns1:code>
<ns1:text>Consumer already exists.</ns1:text>
<ns1:locale>en</ns1:locale>
<ns1:internalCode>CON073</ns1:internalCode>
</ns1:message>
</ns1:messageList>
</AddConsumer>
</MsgData>
<ErrCde>SVC000</ErrCde>
<ErrMsg>Success</ErrMsg>
</Svc>
<ErrCde>MVE000</ErrCde>
<ErrMsg>Success</ErrMsg>
</EbAbcdSvcRes>
</soapenv:Body>
</soapenv:Envelope>

2 Replies

  • Finan's avatar
    Finan
    Frequent Contributor
    Have you tried:
    def node = holder.getDomNode( "//ns1:messageList[1]/ns1:message[1]/ns1:type" )

    instead of:
    def node = holder.getDomNode( "//ns1:messageList[1]/message[1]/type" )
  • Hi Finan,

    I tried with that also but still i am getting "null" for node.nodeValue. Please see below "log output"

    import com.eviware.soapui.support.XmlHolder

    def holder = new XmlHolder( messageExchange.responseContentAsXml )

    holder.namespaces["ns1"] = "http://metavante.com/types/common"

    def node = holder.getDomNode( "//ns1:messageList[1]/ns1:message[1]/ns1:type" )

    log.info node.nodeValue

    assert node != "BUSINESS_LOGIC_ERROR"

    =====================================================================


    log output


    Tue Jul 05 11:36:59 IST 2011:INFO:null