Skip to content

validation error for valid xml [SWS-35] #188

@gregturn

Description

@gregturn

Ingo opened SWS-35 and commented

I've created a web service and i get a validation error in the log file.

DEBUG webservice.CreateDataTypesRequestEndpoint - Marshalling [javax.xml.bind.JAXBElement@1873ad9] to response payload
ERROR endpoint.PayloadValidatingInterceptor - XML validation error on response: UndeclaredPrefix: Cannot resolve 'ns2:AddressDataType' as a QName: the prefix 'ns2' is not declared.
ERROR endpoint.PayloadValidatingInterceptor - XML validation error on response: cvc-elt.4.1: The value 'ns2:AddressDataType' of attribute 'http://www.w3.org/2001/XMLSchema-instance,type' of element 'ns2:casDataType' is not a valid QName.
ERROR endpoint.PayloadValidatingInterceptor - XML validation error on response: UndeclaredPrefix: Cannot resolve 'ns2:AddressDataType' as a QName: the prefix 'ns2' is not declared.
ERROR endpoint.PayloadValidatingInterceptor - XML validation error on response: cvc-attribute.3: The value 'ns2:AddressDataType' of attribute 'xsi:type' on element 'ns2:casDataType' is not valid with respect to its type, 'QName'.
ERROR endpoint.PayloadValidatingInterceptor - XML validation error on response: cvc-complex-type.2.4.d: Invalid content was found starting with element 'ns2:firstName'. No child element is expected at this point.

The following code is my SOAP response:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header />
SOAP-ENV:Body
<ns2:createDataTypesResponse xmlns:ns2="http://springws.cas.de">
<ns2:casDataType
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="ns2:AddressDataType">
ns2:key123</ns2:key>
ns2:firstNameFritz</ns2:firstName>
ns2:lastNameMeier</ns2:lastName>
</ns2:casDataType>
</ns2:createDataTypesResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

My XSD looks like this:

<?xml version="1.0" encoding="UTF-8"?>

<schema
xmlns="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="qualified"
targetNamespace="http://springws.cas.de"
xmlns:tns="http://springws.cas.de" >

<complexType name="CasDataType" >
	<sequence>
		<element name="key"		type="long"		nillable="false" minOccurs="1" maxOccurs="1"/>
	</sequence>
</complexType>

<complexType name="AddressDataType">
	<complexContent>
		<extension base="tns:CasDataType">
			<sequence>
				<element name="firstName"	nillable="true" minOccurs="0" type="string"/>
				<element name="lastName"	nillable="true" minOccurs="0" type="string"/>
			</sequence>
		</extension>
	</complexContent>
</complexType>

<complexType name="ArrayOfCasDataTypes">
	<sequence>
		<element name="casDataType" 		type="tns:CasDataType"	nillable="false" minOccurs="1" maxOccurs="unbounded"/>
	</sequence>
</complexType>

<element name="createDataTypesRequest"  type="tns:ArrayOfCasDataTypes"/>

<element name="createDataTypesResponse" type="tns:ArrayOfCasDataTypes"/>

</schema>
This code says that my xml is valid:
SchemaFactory factory = SchemaFactory.newInstance(XMLConstants. W3C_XML_SCHEMA_NS_URI);
Schema schema = factory.newSchema(new File("schema.xsd"));
Validator validator = schema.newValidator();
validator.validate(new StreamSource(new File("payload.xml")));


Affects: 1.0 M1

Metadata

Metadata

Assignees

Labels

status: declinedA suggestion or change that we don't feel we should currently applytype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions