Forum Discussion

usingsoap's avatar
usingsoap
New Contributor
11 years ago

Help with Assertions

Hello,

Using SoapUI Pro and I'm trying to assert that the ClaimNumber value is a certain length (9 characters long). There are multiple ClaimNumbers returned in the response and they will all be 9 characters long. I just need to grab any one of them and validate the length. Any help would be greatly appreciated!


Example:
<ClaimNumber xsi:type="soapenc:string">048905767</ClaimNumber>
<ExposureId xsi:type="soapenc:string">cc:42669</ExposureId>

6 Replies

  • nmrao's avatar
    nmrao
    Icon for Champion Level 1 rankChampion Level 1
    Check with the wsdl provider if that validation is present at schema level, then you may have schema compliance assertion which will validation.
    Otherway, you can do string length as well using xpath assertion, the expected output should be 'true' (check the namespaces if the below xpath does not work)

    string-length(//ClaimNumber/text())='9'
  • usingsoap's avatar
    usingsoap
    New Contributor
    Thanks for that assistance. I tried using the code you sent below and it fails with the following reason:

    XPathContains assertion failed for path [string-length(//ClaimNumber/text())='9'] : RuntimeException:net.sf.saxon.trans.XPathException: Cannot compare xs:integer to xs:string

    I'm not sure what you meant by check the namespace or if this failure is even related to that. Any thoughts on this?

    thanks!
  • nmrao's avatar
    nmrao
    Icon for Champion Level 1 rankChampion Level 1
    Please post complete response. By the way have you tried removing single quote around 9?
  • How to add multiple assertion for Dynamic Response

    Here, i am using DataSource to take Request. If my first response contain Valid message, 2nd Response contain 'XXX' message and 3rd Response contain 'YYY' message.
    Can we add multiple assertion for dynamic response and how ?
    I came to know we can use Groovy script but don't know what to do in that case.

    I am using below script

    def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
    def response = context.expand( 'http://xmlns.bmogc.net/MDMCEMErrorInfo/1_0' )
    def refNum = response.getNodeValue("//detail[1]/out:ErrorInfo[1]/out:exceptionControl[1]/out:errorMessage[1]/text()");

    if refNum == ('The Email Id is not present for the requested Portal type')
    {
    asser 1=1;
    }


    But i am facing below error

    Fri Dec 05 14:10:01 EST 2014:ERROR:org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
    Script32.groovy: 7: unexpected token: = @ line 7, column 10.
    assert 1=1;
    ^
    org.codehaus.groovy.syntax.SyntaxException: unexpected token: = @ line 7, column 10.


    1 error
  • umeriftikhar's avatar
    umeriftikhar
    Occasional Contributor
    Hi,

    this function is giving no error:
    def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )

    but when i call this function:
    def holder = groovyUtils.getXml( mockRequest.requestContent )

    i get this error:
    ERROR:An error occurred [com.eviware.soapui.impl.wsdl.mock.DispatchException: Failed to dispatch using script; java.lang.NullPointerException], see error log for details
  • nmrao's avatar
    nmrao
    Icon for Champion Level 1 rankChampion Level 1
    Please do not cross post. Locking this topic.