SOAPUI: confirmation of response to xsd schema file

How can I check the SOAP response to an XSD file that defines the response scheme. the web service that I am calling has an XMLDocument as input and output, so it cannot use WSDL to check the response scheme.

+7
wsdl xsd soapui
source share
3 answers

In case you still need it (valid for version 1.5.1 SOAP): File, Settings, Editor settings, Verification of the answer.

+21
source share

Use the script statement:

def project = messageExchange.modelItem.testStep.testCase.testSuite.project

def wsdlcontext = project.getInterfaceAt (0) .getDefinitionContext ()

def validator = new com.eviware.soapui.impl.wsdl.support.wsdl.WsdlValidator (wsdlcontext);

def errors = validator.assertRequest (messageExchange, false)

assert errors.length <1

+1
source share

You can use the groovy script to check the response to the xsd file. Here is a verification method

import javax.xml.transform.stream.StreamSource; import javax.xml.validation.SchemaFactory; import javax.xml.XMLConstants; //Read your xsd file and get the conten into a variable like below. def xsdContent = "Some Schema Standard"; //Take the response into another variable that you have to validate. def actualXMLResponse = "Actual XML Response "; //create a SchemaFactory object def factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); //Create a given schema object with help of factory def schema = factory.newSchema(new StreamSource(new StringReader(xsdContent )); //Create a validator def validator = schema.newValidator(); //now validate the actual response against the given schema try { validator.validate(new StreamSource(new StringReader(actualXMLResponse ))); } catch(Exception e) { log.info (e); assert false; } 

Hope this helps you :-)

0
source share

All Articles