jaxb
  1. jaxb
  2. JAXB-758

Wrong behaviour with xsd:any and a payload with default namespace

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.2
    • Fix Version/s: not determined
    • Component/s: runtime
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      758

      Description

      Hello,
      I am working with Metro 2.1 nightly, JAXB 2.2 and WS-Transfer.
      WS-Transfer elements like Put, Create, ... are providing an xsd:any content
      where I need to add the original payload to be transferred.
      Actually JAXB is erroneously modifying the namespace of a payload with default
      namespace.

      xsd:Any allows almost any content and expecially using skip processing such
      content must be ignored.
      There is no reason to add the outer namespace (e.g. the namespace of a
      ws-transfer "Put" element) to the inner payload.

      Payload's integrity is required to be preserved as it could represent an Invoice
      with an incorporated digital signature.
      This means the receiver must be able to validate the signature against the
      payload content (and this is not possible if the payload is modified on-the-road).
      The transport should not change the payload at all...

      Actually I noted that JAXB has a strange behaviour with either "lax" and "skip"
      processing of the xsd:any if the payload has a default namespace declared into
      its root (xmlns="...").

      Example using LAX or SKIP processing
      ----------------------------------------------------
      Generated by JAXB:

      <ns4:Put xmlns:ns4="[WS-Transfer NS]">
      <Invoice xmlns="" xmlns:ns4="[WS-Transfer NS]" xmlns="[original default NS]" />
      </ns4:Put>

      This is how it should be with the original payload:

      <ns4:Put xmlns:ns4="[WS-Transfer NS]">
      <Invoice xmlns="[original default NS]"/>
      </ns4:Put>

      I believe that xsd:Any "skip" processing should completely ignore the xml
      content and thus the way namespaces are declared in the payload should be
      untouched...

      The same is for "lax" processing if the payload is not using elements from
      declared namespaces in the context (as it is usually for a business payload).

      Example using <jaxb:dom/> xs:annotation
      ----------------------------------------------------
      I made this exercise to avoid a dependancy between Put and its xs:any content.
      I dreamed to see the payload untouched after this change but I was wrong.

      <xs:element name="Put">
      <xs:complexType>
      <xs:sequence>
      <xs:any minOccurs="1" maxOccurs="unbounded" namespace="##other"
      processContents="skip">
      <xs:annotation><xs:appinfo>
      <jaxb:dom/>
      </xs:appinfo></xs:annotation>
      </xs:any>
      </xs:sequence>
      <xs:anyAttribute namespace="##other" processContents="lax" />
      </xs:complexType>
      </xs:element>

      Generated by JAXB:

      <ns4:Put xmlns:ns4="[WS-Transfer NS]">
      <Invoice:Invoice xmlns:Invoice="[original default NS]" xmlns:ns4="[WS-Transfer
      NS]" xmlns="[original default NS]" />
      </ns4:Put>

      NOTE: The behaviour is changed a few here, but the namespace "xmlns:Invoice" is
      really undesired and not useful at all.

      This is how the Put should be with the original payload:

      <ns4:Put xmlns:ns4="[WS-Transfer NS]">
      <Invoice xmlns="[original default NS]"/>
      </ns4:Put>

      Payloads with a default namespace are a common case, I really hope this is not a
      real limit of JAXB.

      Please can you suggest a workaround ?

      Thank you in advance for any help

      Best regards

      Roberto Cisternino

        Activity

        cistox created issue -
        kenaiadmin made changes -
        Field Original Value New Value
        issue.field.bugzillaimportkey 758 28843
        Martin Grebac made changes -
        Assignee Martin Grebac [ snajper ] Iaroslav Savytskyi [ yaroska ]

          People

          • Assignee:
            Iaroslav Savytskyi
            Reporter:
            cistox
          • Votes:
            5 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: