Example usage for javax.xml.soap SOAPHeader removeChild

List of usage examples for javax.xml.soap SOAPHeader removeChild

Introduction

In this page you can find the example usage for javax.xml.soap SOAPHeader removeChild.

Prototype

public Node removeChild(Node oldChild) throws DOMException;

Source Link

Document

Removes the child node indicated by oldChild from the list of children, and returns it.

Usage

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

private void appendSecurityHeader(SOAPHeader soapHeader, Element securityElement) {
    soapHeader.removeChild(securityElement);
    soapHeader.appendChild(securityElement);
}

From source file:be.fedict.eid.idp.protocol.ws_federation.sts.WSSecuritySoapHandler.java

private void handleOutboundMessage(SOAPMessageContext context) throws SOAPException {
    SOAPMessage soapMessage = context.getMessage();
    SOAPPart soapPart = soapMessage.getSOAPPart();
    SOAPHeader soapHeader = soapMessage.getSOAPHeader();
    if (null == soapHeader) {
        SOAPEnvelope soapEnvelope = soapPart.getEnvelope();
        soapHeader = soapEnvelope.addHeader();
    }//  w ww .j  a v a  2  s  .co m

    WSSecHeader wsSecHeader = new WSSecHeader();
    Element securityElement;
    try {
        securityElement = wsSecHeader.insertSecurityHeader(soapPart);
    } catch (WSSecurityException e) {
        throw new SOAPException("WS-Security error: " + e.getMessage(), e);
    }
    soapHeader.removeChild(securityElement);
    soapHeader.appendChild(securityElement);

    WSSecTimestamp wsSecTimeStamp = new WSSecTimestamp();
    wsSecTimeStamp.build(soapPart, wsSecHeader);
}