⬅️ **[[$-Tools|Tools]]**
***
# SoapUI
- [Validating XML Messages | Functional Testing](https://www.soapui.org/docs/functional-testing/validating-messages/validating-xml-messages/)
- **Dateien für Projekte** liegen innerhalb ders Installations-Ordners z.B. `C:\Program Files\SmartBear\SoapUI-5.7.0\bin\SoapUI-Project-MCE-IF` für XSD Dateien. So kann diese in einer **Script-Assertion** verwendet werden mit `def xsdLocation = 'SoapUI-Project-MCE-IF/Schema_Artikel.xsd'`
## Code Snippets für Assertions
### XPath Match
- **Declare:** `//DEBUG[1]`
```groovy
// Expected Result
<DEBUG>
<GetAction>show_debug</GetAction>
<PostAction/>
<GetDaten>
<user>admin-wawi</user>
<password>b2636101f317a042ed9fc9d9863b3daf</password>
<action>show_debug</action>
<LimitRowCount>2</LimitRowCount>
<LimitOffset>2</LimitOffset>
<SkipImages>TRUE</SkipImages>
<AbDatum>2023-01-01</AbDatum>
</GetDaten>
<PostDaten></PostDaten>
</DEBUG>
```
- **Declare:** `//DEBUG/GetDaten/user`
```groovy
admin-wawi
```
### Script Assertion for XSD check
```groovy
//import groovy.xml.XmlUtil
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.SchemaFactory;
import javax.xml.XMLConstants;
import java.nio.charset.StandardCharsets;
// get the xml response
def response = messageExchange.getResponseContent()
// parse it
def xmlResponse = new XmlSlurper().parseText(response)
def xsdLocation = 'SoapUI-Project-MCE-IF/Schema_Debug.xsd'
//try {
SchemaFactory.newInstance( XMLConstants.W3C_XML_SCHEMA_NS_URI)
.newSchema( new File(xsdLocation))
.newValidator()
.validate(new StreamSource(new StringReader( XmlUtil.serialize(xmlResponse))))
//} catch(MalformedURLException e) {
// log.info (e);
//} catch(Exception e) {
// log.info (e);
// assert false;
//}
```