users@glassfish.java.net

How to add JAXB object to SOAPHeader in JAX-WS SOAPHandler

From: <noreply_at_java.net>
Date: Fri, 05 Nov 2010 09:07:42 -0700

Hi,

I have created a JAX-WS client from a business partner's WSDL. I now have
many JAXB objects for everything in the WSDL/XSD.

They have provided a data structure for me to fill in and add to the
SOAP header which is used for message routing and authentication.  After
doing some reading I think the proper solution is for me to create a
SOAPHandler that intercepts every request and adds the SOAPHeader.  Below is
a snippet of what my handleMessage method looks like:

public boolean handleMessage(SOAPMessageContext msgCtx) { SOAPEnvelope
soapEnvelope; SOAPHeader soapHeader; PartnerHeader partnerHeader; // JAXB
object boolean isOutboundMessage = ((Boolean) msgCtx.get(
SOAPMessageContext.MESSAGE_OUTBOUND_PROPERTY)) .booleanValue(); if
(isOutboundMessage) { try { soapEnvelope =
msgCtx.getMessage().getSOAPPart().getEnvelope(); soapHeader =
envelope.getHeader(); partnerHeader = new PartnerHeader(); // JAXB object //
fill in partnerHeader JAXB object // add partnerHeader to soapHeader } catch
.... { ... } } }
Can someone please show me how to add the filled-in JAXB object into the
SOAPHeader?

 

Thanks,

Ryan


--
[Message sent by forum member 'rdelaplante']
View Post: http://forums.java.net/node/712962