List of usage examples for org.w3c.dom Element getPrefix
public String getPrefix();
null
if it is unspecified. From source file:test.integ.be.fedict.hsm.ws.WSSecurityTestSOAPHandler.java
private void handleOutboundMessage(SOAPMessageContext context) throws SOAPException, DatatypeConfigurationException, CertificateEncodingException, DOMException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, MarshalException, XMLSignatureException, NoSuchProviderException { SOAPMessage soapMessage = context.getMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); Element soapEnvelopeElement = soapPart.getDocumentElement(); String soapPrefix = soapEnvelopeElement.getPrefix(); LOG.debug("SOAP prefix: " + soapPrefix); Element soapHeaderElement = soapPart.createElementNS(SOAP_NAMESPACE, soapPrefix + ":Header"); Element soapBodyElement = (Element) soapEnvelopeElement.getFirstChild(); soapBodyElement.setAttributeNS(XMLNS_NS, "xmlns:wsu", WSU_NAMESPACE); soapBodyElement.setAttributeNS(WSU_NAMESPACE, "wsu:Id", "Body"); soapEnvelopeElement.insertBefore(soapHeaderElement, soapBodyElement); LOG.debug("adding WS-Security SOAP header"); Element wsSecurityHeaderElement = soapPart.createElementNS(WSSE_NAMESPACE, "wsse:Security"); soapHeaderElement.appendChild(wsSecurityHeaderElement); wsSecurityHeaderElement.setAttributeNS(XMLNS_NS, "xmlns:wsse", WSSE_NAMESPACE); wsSecurityHeaderElement.setAttributeNS(XMLNS_NS, "xmlns:wsu", WSU_NAMESPACE); wsSecurityHeaderElement.setAttributeNS(SOAP_NAMESPACE, soapPrefix + ":mustUnderstand", "true"); Element tsElement = addTimestamp(wsSecurityHeaderElement); addBinarySecurityToken(wsSecurityHeaderElement); addSignature(wsSecurityHeaderElement, tsElement, soapBodyElement); }