Java Code Examples for javax.xml.soap.SOAPMessage#getSOAPHeader()
The following examples show how to use
javax.xml.soap.SOAPMessage#getSOAPHeader() .
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: EPRHeader.java From hottub with GNU General Public License v2.0 | 6 votes |
public void writeTo(SOAPMessage saaj) throws SOAPException { try { // TODO what about in-scope namespaces // Not very efficient consider implementing a stream buffer // processor that produces a DOM node from the buffer. Transformer t = XmlUtil.newTransformer(); SOAPHeader header = saaj.getSOAPHeader(); if (header == null) header = saaj.getSOAPPart().getEnvelope().addHeader(); // TODO workaround for oracle xdk bug 16555545, when this bug is fixed the line below can be // uncommented and all lines below, except the catch block, can be removed. // t.transform(epr.asSource(localName), new DOMResult(header)); ByteArrayOutputStream baos = new ByteArrayOutputStream(); XMLStreamWriter w = XMLOutputFactory.newFactory().createXMLStreamWriter(baos); epr.writeTo(localName, w); w.flush(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); DocumentBuilderFactory fac = DocumentBuilderFactory.newInstance(); fac.setNamespaceAware(true); Node eprNode = fac.newDocumentBuilder().parse(bais).getDocumentElement(); Node eprNodeToAdd = header.getOwnerDocument().importNode(eprNode, true); header.appendChild(eprNodeToAdd); } catch (Exception e) { throw new SOAPException(e); } }
Example 2
Source File: OutboundReferenceParameterHeader.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Override public void writeTo(SOAPMessage saaj) throws SOAPException { //TODO: SAAJ returns null instead of throwing SOAPException, // when there is no SOAPHeader in the message, // which leads to NPE. try { SOAPHeader header = saaj.getSOAPHeader(); if (header == null) { header = saaj.getSOAPPart().getEnvelope().addHeader(); } Element node = (Element)infoset.writeTo(header); node.setAttributeNS(AddressingVersion.W3C.nsUri,AddressingVersion.W3C.getPrefix()+":"+IS_REFERENCE_PARAMETER,TRUE_VALUE); } catch (XMLStreamBufferException e) { throw new SOAPException(e); } }
Example 3
Source File: OutboundReferenceParameterHeader.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Override public void writeTo(SOAPMessage saaj) throws SOAPException { //TODO: SAAJ returns null instead of throwing SOAPException, // when there is no SOAPHeader in the message, // which leads to NPE. try { SOAPHeader header = saaj.getSOAPHeader(); if (header == null) { header = saaj.getSOAPPart().getEnvelope().addHeader(); } Element node = (Element)infoset.writeTo(header); node.setAttributeNS(AddressingVersion.W3C.nsUri,AddressingVersion.W3C.getPrefix()+":"+IS_REFERENCE_PARAMETER,TRUE_VALUE); } catch (XMLStreamBufferException e) { throw new SOAPException(e); } }
Example 4
Source File: EPRHeader.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public void writeTo(SOAPMessage saaj) throws SOAPException { try { // TODO what about in-scope namespaces // Not very efficient consider implementing a stream buffer // processor that produces a DOM node from the buffer. Transformer t = XmlUtil.newTransformer(); SOAPHeader header = saaj.getSOAPHeader(); if (header == null) header = saaj.getSOAPPart().getEnvelope().addHeader(); // TODO workaround for oracle xdk bug 16555545, when this bug is fixed the line below can be // uncommented and all lines below, except the catch block, can be removed. // t.transform(epr.asSource(localName), new DOMResult(header)); ByteArrayOutputStream baos = new ByteArrayOutputStream(); XMLStreamWriter w = XMLOutputFactory.newFactory().createXMLStreamWriter(baos); epr.writeTo(localName, w); w.flush(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); DocumentBuilderFactory fac = DocumentBuilderFactory.newInstance(); fac.setNamespaceAware(true); Node eprNode = fac.newDocumentBuilder().parse(bais).getDocumentElement(); Node eprNodeToAdd = header.getOwnerDocument().importNode(eprNode, true); header.appendChild(eprNodeToAdd); } catch (Exception e) { throw new SOAPException(e); } }
Example 5
Source File: AbstractXTeeBaseEndpoint.java From j-road with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private XTeeHeader parseXteeHeader(SOAPMessage paringMessage) throws SOAPException { XTeeHeader pais = new XTeeHeader(); if (paringMessage.getSOAPHeader() == null) { return pais; } SOAPHeader header = paringMessage.getSOAPHeader(); for (Iterator<Node> headerElemendid = header.getChildElements(); headerElemendid.hasNext();) { Node headerElement = headerElemendid.next(); if (!SOAPUtil.isTextNode(headerElement) && headerElement.getFirstChild() != null) { String localName = headerElement.getLocalName(); String value = headerElement.getFirstChild().getNodeValue(); pais.addElement(new QName(headerElement.getNamespaceURI(), localName), value); } } return pais; }
Example 6
Source File: JAXBHeader.java From hottub with GNU General Public License v2.0 | 5 votes |
public void writeTo(SOAPMessage saaj) throws SOAPException { try { SOAPHeader header = saaj.getSOAPHeader(); if (header == null) header = saaj.getSOAPPart().getEnvelope().addHeader(); bridge.marshal(jaxbObject,header); } catch (JAXBException e) { throw new SOAPException(e); } }
Example 7
Source File: DOMHeader.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(); Node clone = header.getOwnerDocument().importNode(node,true); header.appendChild(clone); }
Example 8
Source File: OutboundStreamHeader.java From hottub with GNU General Public License v2.0 | 5 votes |
public void writeTo(SOAPMessage saaj) throws SOAPException { try { SOAPHeader header = saaj.getSOAPHeader(); if (header == null) header = saaj.getSOAPPart().getEnvelope().addHeader(); infoset.writeTo(header); } catch (XMLStreamBufferException e) { throw new SOAPException(e); } }
Example 9
Source File: DOMHeader.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(); Node clone = header.getOwnerDocument().importNode(node,true); header.appendChild(clone); }
Example 10
Source File: XRoadHeaderUtil.java From j-road with Apache License 2.0 | 5 votes |
public static XRoadHeader parseXRoadHeader(SOAPMessage paringMessage) throws SOAPException { XRoadHeader xroadHeader = new XRoadHeader(); SOAPHeader header = paringMessage.getSOAPHeader(); for (Iterator<Node> headerElemendid = header.getChildElements(); headerElemendid.hasNext(); ) { Node headerElement = headerElemendid.next(); if (!SOAPUtil.isTextNode(headerElement) && headerElement.getFirstChild() != null) { XRoadHeaderElement el = parseHeaderElement(headerElement, header); if (el != null) { xroadHeader.addHeaderElement(el); } } } return xroadHeader; }
Example 11
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 12
Source File: AbstractXTeeBaseEndpoint.java From j-road with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") protected XRoadProtocolVersion parseProtocolVersion(SOAPMessage requestMessage) throws SOAPException { XRoadProtocolVersion version = null; // Extract protocol version by headers if (requestMessage.getSOAPHeader() != null) { NodeList reqHeaders = requestMessage.getSOAPHeader().getChildNodes(); for (int i = 0; i < reqHeaders.getLength(); i++) { Node reqHeader = reqHeaders.item(i); if (reqHeader.getNodeType() != Node.ELEMENT_NODE || !reqHeader.getLocalName().equals(XTeeHeader.PROTOCOL_VERSION.getLocalPart())) { continue; } if ((version = XRoadProtocolVersion.getValueByVersionCode(SOAPUtil.getTextContent(reqHeader))) != null) { return version; } } } // Extract protocol version by namespaces SOAPEnvelope soapEnv = requestMessage.getSOAPPart().getEnvelope(); Iterator<String> prefixes = soapEnv.getNamespacePrefixes(); while (prefixes.hasNext()) { String nsPrefix = prefixes.next(); String nsURI = soapEnv.getNamespaceURI(nsPrefix).toLowerCase(); if ((version = XRoadProtocolVersion.getValueByNamespaceURI(nsURI)) != null) { return version; } } throw new IllegalStateException("Unsupported protocol version"); }
Example 13
Source File: JAXBHeader.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public void writeTo(SOAPMessage saaj) throws SOAPException { try { SOAPHeader header = saaj.getSOAPHeader(); if (header == null) header = saaj.getSOAPPart().getEnvelope().addHeader(); bridge.marshal(jaxbObject,header); } catch (JAXBException e) { throw new SOAPException(e); } }
Example 14
Source File: OutboundStreamHeader.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public void writeTo(SOAPMessage saaj) throws SOAPException { try { SOAPHeader header = saaj.getSOAPHeader(); if (header == null) header = saaj.getSOAPPart().getEnvelope().addHeader(); infoset.writeTo(header); } catch (XMLStreamBufferException e) { throw new SOAPException(e); } }
Example 15
Source File: RelatesToHeader.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Override public void writeTo(SOAPMessage saaj) throws SOAPException { SOAPHeader header = saaj.getSOAPHeader(); if (header == null) header = saaj.getSOAPPart().getEnvelope().addHeader(); SOAPHeaderElement she = header.addHeaderElement(name); if (type != null) she.addAttribute(typeAttributeName, type); she.addTextNode(value); }
Example 16
Source File: FaultDetailHeader.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(av.faultDetailTag); she = header.addHeaderElement(new QName(av.nsUri, wrapper)); she.addTextNode(problemValue); }
Example 17
Source File: StringHeader.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(name); if(mustUnderstand) { she.setMustUnderstand(true); } she.addTextNode(value); }
Example 18
Source File: RelatesToHeader.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public void writeTo(SOAPMessage saaj) throws SOAPException { SOAPHeader header = saaj.getSOAPHeader(); if (header == null) header = saaj.getSOAPPart().getEnvelope().addHeader(); SOAPHeaderElement she = header.addHeaderElement(name); if (type != null) she.addAttribute(typeAttributeName, type); she.addTextNode(value); }
Example 19
Source File: FaultDetailHeader.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(av.faultDetailTag); she = header.addHeaderElement(new QName(av.nsUri, wrapper)); she.addTextNode(problemValue); }
Example 20
Source File: StringHeader.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(name); if(mustUnderstand) { she.setMustUnderstand(true); } she.addTextNode(value); }