I initially used POST_PROTOCOL for this outInterceptor - and that returned
headers.size() == 0.
Changing it to: super(Phase.WRITE);
addBefore(SoapOutInterceptor.class.getName());
will still not return the headers.
However this code:
Document document = (Document) requestMessage.getContent(
org.w3c.dom.Node.class );
NodeList nodeList =
document.getElementsByTagNameNS(
EDB_AUT_HEADER_QNAME.getNamespaceURI(),
EDB_AUT_HEADER_QNAME.getLocalPart() );
if ( nodeList.getLength() == 1 )
{
edbHeaderType =
jaxbContext.createUnmarshaller().unmarshal( nodeList.item(
0 ), EDBHeaderType.class ).getValue();
}
is capable of finding it, but is less "clean".
The header *is* present (I use a similar InInterceptor - which IS capable
of getting the headers, and it is:
this( Phase.USER_PROTOCOL );
addAfter( ReadHeadersInterceptor.class.getName() );
2013/6/19 Freeman Fang <[email protected]>
> Hi,
>
> What's the phase for the outInterceptor which you try to retrieve soap
> header?
>
> Also, please double check the request message have the soap header which
> match the QName you specified here.
>
> Please take a look at the outInterceptor I put here which can get headers
> from request message
>
> public class GetSoapHeaderInterceptor extends AbstractSoapInterceptor {
>
> public GetSoapHeaderInterceptor() {
> super(Phase.WRITE);
> addBefore(SoapOutInterceptor.class.getName());
> }
>
> @Override
> public void handleMessage(SoapMessage message) throws Fault {
> if (message.getExchange() != null) {
> if (message.getExchange().getInMessage() instanceof
> SoapMessage) {
> SoapMessage requestMessage = (SoapMessage)
> message.getExchange().getInMessage();
> List<Header> headers = requestMessage.getHeaders();
> System.out.println("header size is " + headers.size());
> }
> }
>
>
> }
>
> }
>
> -------------
> Freeman(Yue) Fang
>
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Web: http://fusesource.com | http://www.redhat.com/
> Twitter: freemanfang
> Blog: http://freemanfang.blogspot.com
> http://blog.sina.com.cn/u/1473905042
> weibo: @Freeman小屋
>
>
>
> On 2013-6-18, at 下午7:48, David Karlsen wrote:
>
> > Hi.
> >
> > I have an serverside outinterceptor, where I need access to a soap header
> > in the correlating incoming request.
> >
> > My code:
> >
> > QName someQnameOfTheSoapHeader = new QName( ns, localname);
> > SoapMessage requestMessage = (SoapMessage)
> > soapMessage.getExchange().getInMessage();
> > Header header = requestMessage.getHeader( someQnameOfTheSoapHeader );
> >
> > but header is null!
> >
> > Any pointers?
> >
> > --
> > David J. M. Karlsen - http://www.linkedin.com/in/davidkarlsen
>
>
--
--
David J. M. Karlsen - http://www.linkedin.com/in/davidkarlsen