Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-3958

Unmarshalling error when using collections of subtypes with the StaxTransformFeature and 'out' transformations

    XMLWordPrintableJSON

Details

    • Unknown

    Description

      We are using the StaxTransformFeature to aid with the versioning of a number or our web services but have hit upon a problem when invoking a web method that returns a collection of subtypes. When the StaxTransformFeature (specifically, the out element transforms) are used, the resultant SOAP payload is malformed, and JAXB cannot unmarshall the collection. Below is an example of the payload we get back:

      <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="xsi">
      <soap:Body>
      <ns2:getVehiclesResponse xmlns:ns2="example-1.0">
      <vehicles>
      <vehicle xsi:type="ns2:bicycle" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <name>Marin</name>
      </vehicle>
      <vehicle xsi:type="ns2:car">
      <name>Ferrari</name>
      </vehicle>
      <vehicle xsi:type="ns2:motorcycle">
      <name>Yamaha</name>
      </vehicle>
      </vehicles>
      </ns2:getVehiclesResponse>
      </soap:Body>
      </soap:Envelope>

      When we invoke the same service, but without the StaxTransformFeature, then we get correct xml and JAXB is happy. A correct payload is shown below. As you can clearly see, the difference between the two is that the correct one includes 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' for each instance of the subtype, whereas the broken one, only has it for the first element in the collection. I have attached a sample project in a zip file that demonstrated the problem. It's a simple maven project, so just run 'mvn test' to see the test failure.

      <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
      <ns2:getVehiclesResponse xmlns:ns2="example-1.0">
      <vehicles>
      <vehicle xsi:type="ns2:bicycle" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <name>Marin</name>
      </vehicle>
      <vehicle xsi:type="ns2:car" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <name>Ferrari</name>
      </vehicle>
      <vehicle xsi:type="ns2:motorcycle" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <name>Yamaha</name>
      </vehicle>
      </vehicles>
      </ns2:getVehiclesResponse>
      </soap:Body>
      </soap:Envelope>

      This is a BLOCKER issue for us at the moment and we require urgent resolution. Can you please advise as to whether there is something we can do to either correct or work around the problem.

      Attachments

        1. cxf-versioning-bug.zip
          55 kB
          Gareth Powell

        Activity

          People

            dkulp Daniel Kulp
            gazpowell Gareth Powell
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: