Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-9066

Include any headers unmarshalled by SoapJaxbDataFormat in content marshalled by the same.

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.12.5, 2.15.3, 2.16.0, 2.14.4, Future
    • 2.16.0
    • camel-soap
    • Any

    • Patch Available
    • Unknown
    • Patch

    Description

      The current implementation of the Soap11DataFormatAdapter and Soap12DataFormatAdapter will never generate SOAP Headers when a JAXB object is the inputObject.

      If the unmarshal is done with ignoreUnmarshalledHeaders set to false, then the SoapJaxbDataFormat.SOAP_UNMARSHALLED_HEADER_LIST message header is populated with a list of Objects or JAXBElement<?>s. However, during the doMarshal, this message header is never referenced. Therefore, the sequence:

      from("direct:source").unmarshal(fromSoapDataFormat).process(doSomething).marshal(toSoapDataFormat).to("mock:end");

      will never produce SOAP Headers in the outbound document.

      The doUnmarshal passes the inputObject and an empty List<JAXBElement<?>> into createContentFromObject. However, is the inputObject is an ordinary JAXB object (or JAXBElement<?>) then no header content will be created, and since the Exchange isn't sent to createContentFromObject, the SoapJaxbDataFormat.SOAP_UNMARSHALLED_HEADER_LIST cannot be referenced.

      It seems to me that, if ignoreUnmarshalledHeaders is false, and the SoapJaxbDataFormat.SOAP_UNMARSHALLED_HEADER_LIST is non-empty, and in the event the inbound Exchange does not contain an Exception, then the contents of the SoapJaxbDataFormat.SOAP_UNMARSHALLED_HEADER_LIST should be added to the headerContent before the call to createContentFromObject.

      I have checked the code for SoapJaxbDataFormat, Soap11DataFormatAdapter and Soap12DataFormatAdapter from camel-soap 2.12.0 through 2.15.2 and it looks like these three classes haven't changed.

      I crated a demo project and patch, originally against JBoss Fuse 6.1.0, but offer it here for the camel-soap 2.12.x branch. I have also applied and tested the patch against camel-soap in the master branch (2.16-SNAPSHOT). Indeed, it looks like this patch can be applied from any point 2.12 and forward.

      The demo can be run against 2.12.5 (or any released version - just change the camel.version property in the POM) to demonstrate what I think is the failure. It can also be run against a patched 2.12.6-SNAPSHOT or 2.16-SNAPSHOT (again, just play around with the camel.version property) to demonstrate what I think is correct behavior.

      Attachments

        1. camel.patch
          5 kB
          Bob Blackard
        2. soapjaxb-header-marshal-example.zip
          20 kB
          Bob Blackard
        3. unit_tests.patch
          20 kB
          Bob Blackard

        Activity

          People

            njiang Willem Jiang
            blackard Bob Blackard
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: