Spring Web Services
  1. Spring Web Services
  2. SWS-339

XML namespace (http://www.w3.org/XML/1998/namespace) mapped to wrong prefix when building WSDL with inlined schemas

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5
    • Fix Version/s: 1.5.1
    • Component/s: Core
    • Labels:
      None

      Description

      When using CommonsXsdSchemaCollection with inline=true, and inlining a schema that use the xml namespace, the WSDL cannot be generated due to the following exception:

      org.xml.sax.SAXParseException: The prefix "xml" cannot be bound to any namespace other than its usual namespace; neither can the namespace for "xml" be bound to any prefix other than "xml".

      InliningXsdSchemaTypesProvider.addTypes should check for the namespace "http://www.w3.org/XML/1998/namespace" and always map it to the prefix "xml"

        Activity

        Hide
        Arjen Poutsma added a comment -

        The xml prefix is always implicitly mapped to http://www.w3.org/XML/1998/namespace, there is no need to map it explicitly in your schema. You can do something like this:

        <xsd:import namespace="http://www.w3.org/XML/1998/namespace"/>

        <xsd:element name="GetOrderRequest">
        <xsd:complexType>
        <xsd:sequence>
        <xsd:element name="child" type="xsd:string"/>
        </xsd:sequence>
        <xsd:attribute ref="xml:lang" use="required"/>
        </xsd:complexType>
        </xsd:element>

        which will result in the following WSDL:

        <wsdl:types>
        <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        targetNamespace="http://www.springframework.org/spring-ws/include/schema"
        xmlns="http://www.springframework.org/spring-ws/include/schema" elementFormDefault="qualified"
        attributeFormDefault="unqualified">

        <xsd:import namespace="http://www.w3.org/XML/1998/namespace"/>

        <xsd:element name="GetOrderRequest">
        <xsd:complexType>
        <xsd:sequence>
        <xsd:element name="child" type="xsd:string"/>
        </xsd:sequence>
        <xsd:attribute ref="xml:lang" use="required"/>
        </xsd:complexType>
        </xsd:element>

        </xsd:schema>
        </wsdl:types>

        Show
        Arjen Poutsma added a comment - The xml prefix is always implicitly mapped to http://www.w3.org/XML/1998/namespace , there is no need to map it explicitly in your schema. You can do something like this: <xsd:import namespace="http://www.w3.org/XML/1998/namespace"/> <xsd:element name="GetOrderRequest"> <xsd:complexType> <xsd:sequence> <xsd:element name="child" type="xsd:string"/> </xsd:sequence> <xsd:attribute ref="xml:lang" use="required"/> </xsd:complexType> </xsd:element> which will result in the following WSDL: <wsdl:types> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.springframework.org/spring-ws/include/schema" xmlns="http://www.springframework.org/spring-ws/include/schema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xsd:import namespace="http://www.w3.org/XML/1998/namespace"/> <xsd:element name="GetOrderRequest"> <xsd:complexType> <xsd:sequence> <xsd:element name="child" type="xsd:string"/> </xsd:sequence> <xsd:attribute ref="xml:lang" use="required"/> </xsd:complexType> </xsd:element> </xsd:schema> </wsdl:types>
        Hide
        Stephen Duncan Jr added a comment -

        My problem, however, is that I use 3rd-party schemas that include a schema location when they import the xml namespace. Then, when inlining all the schemas, the schema for the xml namespace is included in the WSDL, but with a different prefix. I think modfying InliningXsdSchemaTypesProvider.addTypes to special-case the handling a schema with a target namespace of http://www.w3.org/XML/1998/namespace would be appropriate, as this is a problem with real-world standard schemas out there.

        Show
        Stephen Duncan Jr added a comment - My problem, however, is that I use 3rd-party schemas that include a schema location when they import the xml namespace. Then, when inlining all the schemas, the schema for the xml namespace is included in the WSDL, but with a different prefix. I think modfying InliningXsdSchemaTypesProvider.addTypes to special-case the handling a schema with a target namespace of http://www.w3.org/XML/1998/namespace would be appropriate, as this is a problem with real-world standard schemas out there.
        Hide
        Arjen Poutsma added a comment -

        I see. This is actually an issue in CommonsXsdSchemaCollection, which should not follow the schemaLocation for the XML namespace.

        Will fix.

        Show
        Arjen Poutsma added a comment - I see. This is actually an issue in CommonsXsdSchemaCollection, which should not follow the schemaLocation for the XML namespace. Will fix.
        Hide
        Arjen Poutsma added a comment -

        Fixed. Imports of the XML namespace (http://www.w3.org/XML/1998/namespace) are no longer followed.

        Show
        Arjen Poutsma added a comment - Fixed. Imports of the XML namespace ( http://www.w3.org/XML/1998/namespace ) are no longer followed.

          People

          • Assignee:
            Arjen Poutsma
            Reporter:
            Stephen Duncan Jr
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: