Forum Discussion
It would be easy to validate using schema compliance assertion which does the same unless you have any custom requirement.
Thank you for your advice nmrao, but the schema compliance doesn't seem to validate element data types, like if I have a Date element and the actual response value is an integer, the test step will still evaluate to true. Also, we like to control the restriction on some elements, like limiting the length of a string value which may change from time to time, this is why I thought it will be best to validate it against an xsd...
- nmrao8 years agoChampion Level 2I believe that you had same question in the below thread which was accepted answered
https://community.smartbear.com/t5/SoapUI-Open-Source/How-to-verify-response-content-if-it-has-valid-DateTime-or/m-p/136047#M23213
What made you to open another question?- marlonumali8 years agoOccasional Contributor
Thanks nmrao, we like to use xsd validation as we have lots of data fields declaration and restriction that we want to validate, and I thought it would be very tedious to test each field by plain groovy scripts.
Regards,
Marlon
- marlonumali8 years agoOccasional Contributor
I rewrite the schema file and break it into two separate files to allow the use of two different namespaces ("http://schemas.xmlsoap.org/soap/envelope/" and "http://tempuri.org/") in the xml file. I validate the original xml successfully using Eclipse with the two schema files below:
First Schema NewXMLSchema.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tns="http://tempuri.org/"
elementFormDefault="qualified"><import schemaLocation="NewXMLSchema1.xsd" namespace="http://tempuri.org/" >
</import>
<element name="Envelope" type="s:Body" />
<complexType name="Body">
<sequence>
<element name="Body" type="tns:GetDataResponse" />
</sequence>
</complexType>
</schema>The imported Schema NewXMLSchema1.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://tempuri.org/"
xmlns:tns="http://tempuri.org/"
elementFormDefault="qualified"><complexType name="GetDataResponse" >
<sequence>
<element name="GetDataResponse" type="tns:GetDataResult"/>
</sequence>
</complexType>
<complexType name="GetDataResult" >
<sequence>
<element name="GetDataResult" type="string" />
</sequence>
</complexType>
</schema>But when I tried to validate the original xml file in the soapui, i receive the following error message:
src-resolve: Cannot resolve the name 'tns:GetDataResponse' to a(n) 'type of definition' component.
- alexisrl7337 years agoOccasional Contributor
Hello nmrao,
I have an issue when using an xsd file that contains this:
<xsd:include schemaLocation="edist_commontypes.xsd"/>
<xsd:include schemaLocation="aidm_commontypes.xsd"/>
I mean, it "includes" another xsd (reference). How to deal with this? I'm trying to validate an xml file using this xsd file (that also includes reference to another xsd).
- snand6 years agoNew Contributor
Hi alexisrl733 ,
Did you happen to find a solution for this which you have asked ?
It would be of real help.
Thanks,
Sonal
Related Content
- 6 years ago
Recent Discussions
- 2 days ago
- 5 days ago
- 16 days ago