- From: pau carre <pau.carre@gmail.com>
- Date: Mon, 5 Feb 2007 16:31:35 +0100
- To: xmlschema-dev@w3.org
Hi all, I have witten an schema (XSD) using key and keyref elements.
This XSD has been tested successfully with some XML files.
The problem is that when I add this XSD to a WSDL (copy-paste) wrong
soap instances (XML instances in the context of XSD) are validated OK
when they do not fit the keyref constraint (the validation occurs when
calling a WS generated with WSDL2Java)
The XSD is:
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns:tns="http://localhost:8080/hotelres"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://localhost:8080/hotelres"
attributeFormDefault="unqualified" elementFormDefault="qualified"
xmlns="http://www.w3.org/2001/XMLSchema">
<xs:element name="contract">
<xs:complexType>
<xs:sequence>
<xs:element name="roomtypes">
<xs:complexType>
<xs:sequence>
<xs:element
name="roomtype"
type="tns:roomtypeType">
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="sizes">
<xs:complexType>
<xs:sequence>
<xs:element name="size"
type="tns:sizeType" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:string"
use="required" />
</xs:complexType>
<xs:key name="roomtypesCodeID">
<xs:selector xpath="./tns:roomtypes/tns:roomtype" />
<xs:field xpath="@code" />
</xs:key>
<xs:keyref name="roomtypesCodeIDRef"
refer="tns:roomtypesCodeID">
<xs:selector
xpath="./tns:sizes/tns:size/tns:RoomtypeReferences/tns:RoomtypeReference" />
<xs:field xpath="@code" />
</xs:keyref>
</xs:element>
<xs:complexType name="roomtypeType">
<xs:attribute name="code" type="xs:string" use="required" />
</xs:complexType>
<xs:complexType name="sizeType">
<xs:sequence>
<xs:element name="RoomtypeReferences">
<xs:complexType>
<xs:sequence>
<xs:element
name="RoomtypeReference">
<xs:complexType>
<xs:attribute name="code"
type="xs:string" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</schema>
The WSDL is:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="http://localhost:8080/hotelres"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://localhost:8080/hotelres">
<wsdl:types>
<xs:schema attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="http://localhost:8080/hotelres">
<!-- THE SAME SCHEMA AS THE XSD DEFINED ABOVE -->
</xs:schema>
</wsdl:types>
<wsdl:message name="updateContractRQ">
<wsdl:part element="tns:contract" name="parameter"/>
</wsdl:message>
<wsdl:message name="updateContractRS">
<wsdl:part element="tns:contractResponse" name="parameter"/>
</wsdl:message>
<wsdl:portType name="htrBackOffice_SOAP">
<wsdl:operation name="UpdateContract">
<wsdl:input message="tns:updateContractRQ"/>
<wsdl:output message="tns:updateContractRS"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="htrBackOfficeSOAP" type="tns:htrBackOffice_SOAP">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="UpdateContract">
<soap:operation soapAction="urn:UpdateContract"
style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="htrBackOffice">
<wsdl:port binding="tns:htrBackOfficeSOAP"
name="htrBackOfficeSOAP">
<soap:address
location="http://localhost:8080/hhNewSOAP/services/htrBackOfficeSOAP"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
One example of soap message that is validated but is acceptated with
WSDL (the xml acceptated by XSD is the same without soap-specific
elements):
soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:hot="http://localhost:8080/hotelres">
<soapenv:Header/>
<soapenv:Body>
<hot:contract id="A">
<hot:roomtypes>
<hot:roomtype code="AA"/>
</hot:roomtypes>
<hot:sizes>
<hot:size>
<hot:RoomtypeReferences>
<hot:RoomtypeReference code="CC"/>
</hot:RoomtypeReferences>
</hot:size>
</hot:sizes>
</hot:contract>
</soapenv:Body>
</soapenv:Envelope>
Thanks in advance,
Pau.
Received on Monday, 5 February 2007 15:37:32 UTC