Example usage for javax.xml.ws.handler.soap SOAPMessageContext getHeaders

List of usage examples for javax.xml.ws.handler.soap SOAPMessageContext getHeaders

Introduction

In this page you can find the example usage for javax.xml.ws.handler.soap SOAPMessageContext getHeaders.

Prototype

public Object[] getHeaders(QName header, JAXBContext context, boolean allRoles);

Source Link

Document

Gets headers that have a particular qualified name from the message in the message context.

Usage

From source file:be.agiv.security.handler.WSAddressingHandler.java

private void handleInboundMessage(SOAPMessageContext context) {
    String messageId = (String) context.get(MESSAGE_ID_CONTEXT_ATTRIBUTE);
    LOG.debug("checking RelatesTo message id: " + messageId);
    Object[] headers = context.getHeaders(new QName(WSConstants.WS_ADDR_NAMESPACE, "RelatesTo"),
            this.jaxbContext, false);
    for (Object headerObject : headers) {
        JAXBElement<RelatesToType> element = (JAXBElement<RelatesToType>) headerObject;
        RelatesToType relatesTo = element.getValue();
        if (false == messageId.equals(relatesTo.getValue())) {
            throw new ProtocolException("incorrect a:RelatesTo value");
        }/*from w  w  w.j  a  va 2s.c o  m*/
    }
}