private SoapVersion11() { try { XmlOptions options = new XmlOptions(); options.setCompileNoValidation(); options.setCompileNoPvrRule(); options.setCompileDownloadUrls(); options.setCompileNoUpaRule(); options.setValidateTreatLaxAsSkip(); URL soapSchemaXmlResource = ResourceUtils.getResourceWithAbsolutePackagePath( getClass(), "/xsds/", "soapEnvelope.xsd"); soapSchemaXml = XmlUtils.createXmlObject(soapSchemaXmlResource, options); soapSchema = XmlBeans.loadXsd(new XmlObject[] {soapSchemaXml}); soapEnvelopeType = soapSchema.findDocumentType(envelopeQName); soapFaultType = soapSchema.findDocumentType(faultQName); URL soapEncodingXmlResource = ResourceUtils.getResourceWithAbsolutePackagePath( getClass(), "/xsds/", "soapEncoding.xsd"); soapEncodingXml = XmlUtils.createXmlObject(soapEncodingXmlResource, options); } catch (XmlException ex) { throw new SoapBuilderException(ex); } }
private AssertionError[] assertResponse( RestMessageExchange messageExchange, RestRepresentation.Type type) { List<AssertionError> result = new ArrayList<AssertionError>(); QName responseBodyElementName = getResponseBodyElementName(messageExchange); RestRequestInterface restRequest = messageExchange.getRestRequest(); boolean asserted = false; for (RestRepresentation representation : restRequest.getRepresentations(type, messageExchange.getResponseContentType())) { if (representation.getStatus().isEmpty() || representation.getStatus().contains(messageExchange.getResponseStatusCode())) { SchemaType schemaType = representation.getSchemaType(); if (schemaType != null && representation.getElement().equals(responseBodyElementName)) { try { XmlObject xmlObject = schemaType .getTypeSystem() .parse(messageExchange.getResponseContentAsXml(), schemaType, new XmlOptions()); // create internal error list List<?> list = new ArrayList<Object>(); XmlOptions xmlOptions = new XmlOptions(); xmlOptions.setErrorListener(list); xmlOptions.setValidateTreatLaxAsSkip(); xmlObject.validate(xmlOptions); for (Object o : list) { if (o instanceof XmlError) result.add(new AssertionError((XmlError) o)); else result.add(new AssertionError(o.toString())); } asserted = true; } catch (XmlException e) { SoapUI.logError(e); } } else { asserted = true; } } } if (!asserted && result.isEmpty()) { result.add( new AssertionError( "Missing matching representation for request with contentType [" + messageExchange.getResponseContentType() + "]")); } return result.toArray(new AssertionError[result.size()]); }