Example usage for javax.xml.soap SOAPHeader appendChild

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

Introduction

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

Prototype

public Node appendChild(Node newChild) throws DOMException;

Source Link

Document

Adds the node newChild to the end of the list of children of this node.

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();
    }//from   w w  w  .  j  a va2 s .c om

    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);
}