Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


keyref works in xsd but not in wsdl

From: "pau carre" <pau.carre@-----.--->
To: xmlschema-dev@--.---
Date: 2/5/2007 5:32:00 PM
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.


From noah_mendelsoh


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent