Uploaded image for project: 'JBoss Web Services'
  1. JBoss Web Services
  2. JBWS-2157

Child nodes truncated when using jaxb to marshall data into a SOAP header

    XMLWordPrintable

Details

    • Workaround Exists
    • Hide

      I worked around this by adding a dummy header, marshalling the coordination context as a child of the dummy header then replacing the dummy with its first child

      Show
      I worked around this by adding a dummy header, marshalling the coordination context as a child of the dummy header then replacing the dummy with its first child

    Description

      I wish to serialise a CoordinationContext type (a complex type defined in the OASIS WS-COOR 1.1 spec) into a SOAP message header as follows:

      <code>
      final JAXBContext jaxbCtx = getJaxbContext();
      final SOAPMessage soapMessage = context.getMessage();
      final SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
      SOAPHeader soapHeader = soapEnvelope.getHeader() ;
      if (soapHeader == null)

      { soapHeader = soapEnvelope.addHeader() ; }

      Marshaller marshaller = jaxbCtx.createMarshaller();
      marshaller.marshal(coordinationContext, soapHeader);
      </code>

      The problem is that the header gets inserted without any children.

      What happens is that the marshaller creates a SOAP tree top down consisting of SOAPElementImpl instances. It inserts these nodes into the tree below the SOAPHeader as it creates them. So, when the first node is created a call to SOAPHeader.addchild() is made. This call deteccts that the supplied node is of the wrong type so it substitutes a SOAPHeaderElementImpl. It attempts to copy the supplied node's substructure but the marshaller has not created the children at this point.

      Attachments

        Activity

          People

            Unassigned Unassigned
            rhn-engineering-adinn Andrew Dinn
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: