title: SoapUI- How to assert from a response
body: <p>I am new to SoapUI I have a basic question. When i get a response to a services i would like to do an assert for a value. below is scripts i had created under Script Assertion </p>
  
  <pre><code>import com.eviware.soapui.support.XmlHolder
  
  def holder = new XmlHolder(messageExchange.responseContentAsXml)
  assert holder["//ConstraintId[0]"] =="5000006";
  
  I get the following error:
  assert holder["//ConstraintId[0]"] =="5000006" | | | | [] false com.eviware.soapui.support.XmlHolder@8b6500 (toString() threw java.lang.NullPointerException)
  
  **********************************************************
  import org.xml.sax.helpers.DefaultHandler
  
  def rootNode = new XmlSlurper().parseText(messageExchange.responseContentAsXml)
  assert rootNode.Body.Constraintid[0].text=="5000006";
  
  I get the following error:
  assert rootNode.Body.Constraintid[0].text=="5000006" | | | | | | | | | | | false | | | | groovy.util.slurpersupport.NodeChildren@17a5c01 (toString() == "") | | | groovy.util.slurpersupport.NoChildren@2e80e1 (toString() == "") | | groovy.util.slurpersupport.NodeChildren@10f682f (toString() == "") | 
  
  Response
     &lt;soap:Body&gt;
        &lt;GetEnumResponse xmlns="http://www.xyz.com/"&gt;
           &lt;GetEnumResult&gt;
              &lt;ErrorCode&gt;0&lt;/ErrorCode&gt;
              &lt;StatusId&gt;0&lt;/StatusId&gt;
           &lt;/GetEnumResult&gt;
           &lt;enumsInformation&gt;
              &lt;EnumInformation&gt;
                 &lt;TransactionId&gt;0&lt;/TransactionId&gt;
                 &lt;ConstraintId&gt;5000006&lt;/ConstraintId&gt;
                 &lt;EnumValue&gt;abc&lt;/EnumValue&gt;
                 &lt;Index&gt;10&lt;/Index&gt;
              &lt;/EnumInformation&gt;
           &lt;/enumsInformation&gt;
        &lt;/GetEnumResponse&gt;
     &lt;/soap:Body&gt;
  </code></pre>