You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Eric Hodges <eh...@usdataworks.com> on 2009/06/24 19:59:43 UTC

SOAP vs REST XML Schema Validation

I'm developing SOAP and REST web services that do the same thing.  I'm trying
to share the same XSD schema for the message objects, and I'm trying to use
schema validation.

The REST validation works as expected, but the SOAP validation complains
like this:

  "Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid
content was found starting with element 'Site'. One of
'{"http://www.usdataworks.com/realTimePayments/":Site}' is expected."

Why is SOAP expecting a namespace on that element when REST isn't?

Is there some way to tell SOAP not to expect a namespace?

Thanks.
-- 
View this message in context: http://www.nabble.com/SOAP-vs-REST-XML-Schema-Validation-tp24189831p24189831.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: SOAP vs REST XML Schema Validation

Posted by Daniel Kulp <dk...@apache.org>.
This has some roots in the support for the WSI-Basic Profile.  The WSI-BP
 SPECIFICALLY disallows non-qualified elements as direct children of the 
soap:body.   See:
http://www.ws-i.org/Profiles/BasicProfile-1.0-2004-04-16.html#refinement16462544 

Thus, if CXF encounters schemas that don't have a target namespace
that is used for direct children of the body, it adds the namespace of the service.

My suggestion is to set a targetNamespace for the schema and change to
elementFormDefault="unqualified".  In that way, just the "root" elements 
would be qualified in both cases and can meet the requirements of the WSI-BP.

Dan


On Wed June 24 2009 3:51:22 pm Eric Hodges wrote:
> dkulp wrote:
> > Any chance you can capture the two soap messages (soap and rest) as well
> > as
> > attach the schema? (and/or the wsdl for the soap service)   That MAY be
> > able
> > to help diagnose why.
>
> I'd rather not post the full thing here.  Each message has an element named
> "Site".  Each uses the same XSD document.  I import it into the WSDL like
> this:
>
> <wsdl:types>
> 	<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
> 		<xsd:import namespace='' schemaLocation="batchTrigger.xsd">
> 		</xsd:import>
> 	</xsd:schema>
> </wsdl:types>
>
> Inside the XSD, the element and attribute form defaults are this:
>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> 	elementFormDefault="qualified" attributeFormDefault="unqualified">

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

Re: SOAP vs REST XML Schema Validation

Posted by Eric Hodges <eh...@usdataworks.com>.

dkulp wrote:
> 
> Any chance you can capture the two soap messages (soap and rest) as well
> as 
> attach the schema? (and/or the wsdl for the soap service)   That MAY be
> able 
> to help diagnose why.
> 

I'd rather not post the full thing here.  Each message has an element named
"Site".  Each uses the same XSD document.  I import it into the WSDL like
this:

<wsdl:types>
	<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
		<xsd:import namespace='' schemaLocation="batchTrigger.xsd">
		</xsd:import>
	</xsd:schema>
</wsdl:types>

Inside the XSD, the element and attribute form defaults are this:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
	elementFormDefault="qualified" attributeFormDefault="unqualified">

-- 
View this message in context: http://www.nabble.com/SOAP-vs-REST-XML-Schema-Validation-tp24189831p24191752.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: SOAP vs REST XML Schema Validation

Posted by Daniel Kulp <dk...@apache.org>.
Any chance you can capture the two soap messages (soap and rest) as well as 
attach the schema? (and/or the wsdl for the soap service)   That MAY be able 
to help diagnose why.


Dan

On Wed June 24 2009 1:59:43 pm Eric Hodges wrote:
> I'm developing SOAP and REST web services that do the same thing.  I'm
> trying to share the same XSD schema for the message objects, and I'm trying
> to use schema validation.
>
> The REST validation works as expected, but the SOAP validation complains
> like this:
>
>   "Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a:
> Invalid content was found starting with element 'Site'. One of
> '{"http://www.usdataworks.com/realTimePayments/":Site}' is expected."
>
> Why is SOAP expecting a namespace on that element when REST isn't?
>
> Is there some way to tell SOAP not to expect a namespace?
>
> Thanks.

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog