Announcement Announcement Module
Collapse
No announcement yet.
Processing SOAP header Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Processing SOAP header

    We are trying create an interceptor to process a custom soap header that contains authentication information. The header is always logged out as an empty string when we try to process it. The SoapEnvelopeLoggingInterceptor logs the messages out as submitted. Below is the code we are trying to use to retrieve header value. Is there some incorrect with this??

    public boolean handleRequest(MessageContext messageContext, Object endpoint) {
    WebServiceMessage message = messageContext.getRequest();
    SoapMessage soapMessage = (SoapMessage) requestMessage;

    SoapHeader soapHeader = soapMessage.getSoapHeader();
    Iterator<SoapHeaderElement> iterator = (Iterator<SoapHeaderElement>)soapHeader.examineAll HeaderElements();
    while (iterator.hasNext()) {
    SoapHeaderElement header = iterator.next();
    String headerName = header.getName().getLocalPart();

    if(headerName.equalsIgnoreCase("myheader")) {
    logger.debug("HEADER text : '" + header.getText() + "'");
    }
    return true;
    }

  • #2
    and to answer my own question... the following seems to work.

    SoapMessage soapMessage = (SoapMessage) requestMessage;

    SoapHeader soapHeader = soapMessage.getSoapHeader();
    Iterator<SoapHeaderElement> iterator = (Iterator<SoapHeaderElement>)soapHeader.examineAll HeaderElements();

    while (iterator.hasNext()) {
    SoapHeaderElement header = iterator.next();
    String headerName = header.getName().getLocalPart();

    if(headerName.equalsIgnoreCase("myheader")) {
    DOMSource domsource = (DOMSource) header.getSource();
    }
    }

    Comment

    Working...
    X