Marshalling JAXB element over SOAPHeader produces an empty element
------------------------------------------------------------------
Key: JBWS-2572
URL:
https://jira.jboss.org/jira/browse/JBWS-2572
Project: JBoss Web Services
Issue Type: Bug
Security Level: Public (Everyone can see)
Components: jbossws-native
Affects Versions: jbossws-native-3.0.5
Environment: JDK 1.6, JBoss 4.2.3, Ubuntu Linux 8.10
Reporter: Jose Antonio
Hello, I'm trying to set some ws security headers manually in a handler for a Web
service client and server. I have generated JAXB bindings from WS Security schema and in
the client, I generate a Security element with a UserNameToken inside. Then, I try to put
it in the headers in my handler like this:
public boolean handleMessage(SOAPMessageContext context) {
............................................
ObjectFactory fact = new ObjectFactory();
JAXBElement<SecurityHeaderType> secHead = fact.createSecurity(sec);
Marshaller marshaller = ctx.createMarshaller();
SOAPEnvelope envelope = context.getMessage().getSOAPPart().getEnvelope();
SOAPHeader header = (envelope.getHeader() == null) ? envelope.addHeader() :
envelope.getHeader();
marshaller.marshal(secHead,header);
sec is a JAXB element with the Security element content and is not null and not empty. If
I execute my client with this handler in local, using JAX-WS RI 2.1, I get the expected
behavior and I get a header with a Security element and a UserNameToken inside. But when I
deploy my client in JBoss and try to execute it, I get an empty Security element. There is
no UserNameToken inside.
I tried the following workaround and it works for JBoss:
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = builder.newDocument();
marshaller.marshal(secHead, doc);
SOAPFactory sFact = SOAPFactory.newInstance();
header.appendChild(sFact.createElement(doc.getDocumentElement()));
However, it's not the optimum way of doing it, since I need to create two factories
and an intermediary document only to append a child to a header, while it could be done
only with one sencence.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira