Java Code Examples for javax.xml.soap.SOAPHeaderElement#addChildElement()
The following examples show how to use
javax.xml.soap.SOAPHeaderElement#addChildElement() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JPlagClientAccessHandler.java From jplag with GNU General Public License v3.0 | 6 votes |
/** * Adds an "Access" element to the SOAP header */ public boolean handleRequest(MessageContext msgct) { if (msgct instanceof SOAPMessageContext) { SOAPMessageContext smsgct = (SOAPMessageContext) msgct; try { SOAPMessage msg = smsgct.getMessage(); SOAPEnvelope envelope = msg.getSOAPPart().getEnvelope(); SOAPHeader header = msg.getSOAPHeader(); if (header == null) header = envelope.addHeader(); // add an header if non exists SOAPHeaderElement accessElement = header.addHeaderElement(envelope.createName("Access", "ns0", JPLAG_TYPES_NS)); SOAPElement usernameelem = accessElement.addChildElement("username"); usernameelem.addTextNode(username); SOAPElement passwordelem = accessElement.addChildElement("password"); passwordelem.addTextNode(password); SOAPElement compatelem = accessElement.addChildElement("compatLevel"); compatelem.addTextNode(compatibilityLevel + ""); } catch (SOAPException x) { System.out.println("Unable to create access SOAP header!"); x.printStackTrace(); } } return true; }
Example 2
Source File: ProblemActionHeader.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public void writeTo(SOAPMessage saaj) throws SOAPException { SOAPHeader header = saaj.getSOAPHeader(); if(header == null) header = saaj.getSOAPPart().getEnvelope().addHeader(); SOAPHeaderElement she = header.addHeaderElement(new QName(getNamespaceURI(), getLocalPart())); she.addChildElement(actionLocalName); she.addTextNode(action); if (soapAction != null) { she.addChildElement(soapActionLocalName); she.addTextNode(soapAction); } }
Example 3
Source File: ProblemActionHeader.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public void writeTo(SOAPMessage saaj) throws SOAPException { SOAPHeader header = saaj.getSOAPHeader(); if(header == null) header = saaj.getSOAPPart().getEnvelope().addHeader(); SOAPHeaderElement she = header.addHeaderElement(new QName(getNamespaceURI(), getLocalPart())); she.addChildElement(actionLocalName); she.addTextNode(action); if (soapAction != null) { she.addChildElement(soapActionLocalName); she.addTextNode(soapAction); } }
Example 4
Source File: ProblemActionHeader.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public void writeTo(SOAPMessage saaj) throws SOAPException { SOAPHeader header = saaj.getSOAPHeader(); if(header == null) header = saaj.getSOAPPart().getEnvelope().addHeader(); SOAPHeaderElement she = header.addHeaderElement(new QName(getNamespaceURI(), getLocalPart())); she.addChildElement(actionLocalName); she.addTextNode(action); if (soapAction != null) { she.addChildElement(soapActionLocalName); she.addTextNode(soapAction); } }
Example 5
Source File: ProblemActionHeader.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public void writeTo(SOAPMessage saaj) throws SOAPException { SOAPHeader header = saaj.getSOAPHeader(); if(header == null) header = saaj.getSOAPPart().getEnvelope().addHeader(); SOAPHeaderElement she = header.addHeaderElement(new QName(getNamespaceURI(), getLocalPart())); she.addChildElement(actionLocalName); she.addTextNode(action); if (soapAction != null) { she.addChildElement(soapActionLocalName); she.addTextNode(soapAction); } }
Example 6
Source File: ProblemActionHeader.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public void writeTo(SOAPMessage saaj) throws SOAPException { SOAPHeader header = saaj.getSOAPHeader(); if(header == null) header = saaj.getSOAPPart().getEnvelope().addHeader(); SOAPHeaderElement she = header.addHeaderElement(new QName(getNamespaceURI(), getLocalPart())); she.addChildElement(actionLocalName); she.addTextNode(action); if (soapAction != null) { she.addChildElement(soapActionLocalName); she.addTextNode(soapAction); } }
Example 7
Source File: HeaderImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override public SOAPHeaderElement addUpgradeHeaderElement(Iterator supportedSoapUris) throws SOAPException { if (supportedSoapUris == null) { log.severe("SAAJ0411.ver1_2.no.null.supportedURIs"); throw new SOAPException("Argument cannot be null; iterator of supportedURIs cannot be null"); } if (!supportedSoapUris.hasNext()) { log.severe("SAAJ0412.ver1_2.no.empty.list.of.supportedURIs"); throw new SOAPException("List of supported URIs cannot be empty"); } Name upgradeName = getUpgradeName(); SOAPHeaderElement upgradeHeaderElement = (SOAPHeaderElement) addChildElement(upgradeName); Name supportedEnvelopeName = getSupportedEnvelopeName(); int i = 0; while (supportedSoapUris.hasNext()) { SOAPElement subElement = upgradeHeaderElement.addChildElement(supportedEnvelopeName); String ns = "ns" + Integer.toString(i); subElement.addAttribute( NameImpl.createFromUnqualifiedName("qname"), ns + ":Envelope"); subElement.addNamespaceDeclaration( ns, (String) supportedSoapUris.next()); i ++; } return upgradeHeaderElement; }
Example 8
Source File: HeaderImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override public SOAPHeaderElement addUpgradeHeaderElement(String[] supportedSoapUris) throws SOAPException { if (supportedSoapUris == null) { log.severe("SAAJ0411.ver1_2.no.null.supportedURIs"); throw new SOAPException("Argument cannot be null; array of supportedURIs cannot be null"); } if (supportedSoapUris.length == 0) { log.severe("SAAJ0412.ver1_2.no.empty.list.of.supportedURIs"); throw new SOAPException("List of supported URIs cannot be empty"); } Name upgradeName = getUpgradeName(); SOAPHeaderElement upgradeHeaderElement = (SOAPHeaderElement) addChildElement(upgradeName); Name supportedEnvelopeName = getSupportedEnvelopeName(); for (int i = 0; i < supportedSoapUris.length; i ++) { SOAPElement subElement = upgradeHeaderElement.addChildElement(supportedEnvelopeName); String ns = "ns" + Integer.toString(i); subElement.addAttribute( NameImpl.createFromUnqualifiedName("qname"), ns + ":Envelope"); subElement.addNamespaceDeclaration(ns, supportedSoapUris[i]); } return upgradeHeaderElement; }
Example 9
Source File: ProblemActionHeader.java From hottub with GNU General Public License v2.0 | 5 votes |
public void writeTo(SOAPMessage saaj) throws SOAPException { SOAPHeader header = saaj.getSOAPHeader(); if(header == null) header = saaj.getSOAPPart().getEnvelope().addHeader(); SOAPHeaderElement she = header.addHeaderElement(new QName(getNamespaceURI(), getLocalPart())); she.addChildElement(actionLocalName); she.addTextNode(action); if (soapAction != null) { she.addChildElement(soapActionLocalName); she.addTextNode(soapAction); } }
Example 10
Source File: ProblemActionHeader.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public void writeTo(SOAPMessage saaj) throws SOAPException { SOAPHeader header = saaj.getSOAPHeader(); if(header == null) header = saaj.getSOAPPart().getEnvelope().addHeader(); SOAPHeaderElement she = header.addHeaderElement(new QName(getNamespaceURI(), getLocalPart())); she.addChildElement(actionLocalName); she.addTextNode(action); if (soapAction != null) { she.addChildElement(soapActionLocalName); she.addTextNode(soapAction); } }
Example 11
Source File: ProblemActionHeader.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public void writeTo(SOAPMessage saaj) throws SOAPException { SOAPHeader header = saaj.getSOAPHeader(); if(header == null) header = saaj.getSOAPPart().getEnvelope().addHeader(); SOAPHeaderElement she = header.addHeaderElement(new QName(getNamespaceURI(), getLocalPart())); she.addChildElement(actionLocalName); she.addTextNode(action); if (soapAction != null) { she.addChildElement(soapActionLocalName); she.addTextNode(soapAction); } }
Example 12
Source File: SecureSoapMessages.java From spring-ws-security-soap-example with MIT License | 5 votes |
private static final SOAPMessage getMessageToSign(final String pathBase) throws SOAPException, IOException { final SOAPMessage soapMessage; final SOAPPart soapPart; final SOAPEnvelope soapEnvelope; final SOAPHeader soapHeader; final SOAPHeaderElement secElement; final SOAPElement binaryTokenElement; soapMessage = SoapMessageUtils.getMessage(pathBase); soapPart = soapMessage.getSOAPPart(); soapEnvelope = soapPart.getEnvelope(); soapHeader = soapEnvelope.getHeader(); secElement = soapHeader.addHeaderElement(soapEnvelope.createName( "Security", "wsse", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd")); binaryTokenElement = secElement.addChildElement(soapEnvelope.createName( "BinarySecurityToken", "wsse", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd")); binaryTokenElement.setAttribute("EncodingType", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"); binaryTokenElement.setAttribute("ValueType", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"); return soapMessage; }
Example 13
Source File: JPlagClientAccessHandler.java From jplag with GNU General Public License v3.0 | 5 votes |
/** * Adds an "Access" element to the SOAP header */ public boolean handleRequest(MessageContext msgct) { if(msgct instanceof SOAPMessageContext) { SOAPMessageContext smsgct=(SOAPMessageContext) msgct; try { SOAPMessage msg=smsgct.getMessage(); SOAPEnvelope envelope=msg.getSOAPPart().getEnvelope(); SOAPHeader header=msg.getSOAPHeader(); if(header==null) header=envelope.addHeader(); // add an header if non exists SOAPHeaderElement accessElement=header.addHeaderElement( envelope.createName("Access","ns0", "http://www.ipd.uni-karlsruhe.de/jplag/types")); SOAPElement usernameelem=accessElement.addChildElement( "username"); usernameelem.addTextNode(username); SOAPElement passwordelem=accessElement.addChildElement( "password"); passwordelem.addTextNode(password); SOAPElement compatelem=accessElement.addChildElement( "compatLevel"); compatelem.addTextNode(compatibilityLevel+""); } catch (SOAPException x) { System.out.println("Unable to create access SOAP header!"); x.printStackTrace(); } } return true; }