Forum Discussion

Qasvat's avatar
Qasvat
Occasional Contributor
14 years ago

[Resolved]Assertion for checking entire XML-response message

Hello,

I am currently struggling with automatically checking response messages in soapUI pro 4.0.
What I want to do is check, whether the XML-response caused by a request matches exactly(!) the response message specified. So basically it’s just about comparing 2 XML-messages with each other.

Unfortunately I could not find out yet, how to do this in soapUI.
XPath Match doesn’t work for me, because I don’t want to just compare single nodes, but the entire response message.

So I tried my luck using the “contains”-assertion and just paste the specified content of the message into the content-field.
However, the assertion fails with the error message “missing token...”. I also removed all blanks and tabs from the message, but the problem remains.

Does anyone have an idea how to solve this issue?

4 Replies

  • Hi, this seems to be a bug (reported as SOAPUI-2562).

    Let me get back to you tomorrow to tell you how you can get around it by using Script Assertions.


    Regards

    Henrik
    SmartBear Stockholm
  • Hi again!

    So, the workaround would be to create a Script assertion with the following content (this example if for the sample project; just replace the XML string to suit your needs):

    import com.eviware.soapui.support.XmlHolder
    xmlHolder = new XmlHolder( messageExchange.responseContentAsXml )
    assert xmlHolder.getXml() == '''<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sam="http://www.example.org/sample/">
    <soapenv:Header/>
    <soapenv:Body>
    <sam:loginResponse>
    <sessionid>8226660973167617</sessionid>
    </sam:loginResponse>
    </soapenv:Body>
    </soapenv:Envelope>'''


    I have requested the soapUI team to get back to you once this bug has been fixed.

    Have a nice day!

    Henrik
    SmartBear Stockholm