javax.xml.soap.SOAPHeader Java Examples
The following examples show how to use
javax.xml.soap.SOAPHeader.
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: XRoadProtocolNamespaceStrategyV4.java From j-road with Apache License 2.0 | 7 votes |
private void addClientElements(SOAPEnvelope env, XRoadServiceConfiguration conf, SOAPHeader header) throws SOAPException { // TODO: maybe we should create headers differently according to object type? XroadObjectType objectType = conf.getClientObjectType() != null ? conf.getClientObjectType() : XroadObjectType.SUBSYSTEM; SOAPElement client = header.addChildElement("client", protocol.getNamespacePrefix()); client.addAttribute(env.createName("id:objectType"), objectType.name()); SOAPElement clientXRoadInstance = client.addChildElement("xRoadInstance", "id"); clientXRoadInstance.addTextNode(conf.getClientXRoadInstance()); SOAPElement clientMemberClass = client.addChildElement("memberClass", "id"); clientMemberClass.addTextNode(conf.getClientMemberClass()); SOAPElement clientMemberCode = client.addChildElement("memberCode", "id"); clientMemberCode.addTextNode(conf.getClientMemberCode()); if (StringUtils.isNotBlank(conf.getClientSubsystemCode())) { SOAPElement clientSubsystemCode = client.addChildElement("subsystemCode", "id"); clientSubsystemCode.addTextNode(conf.getClientSubsystemCode()); } }
Example #2
Source File: SAAJMessageHeaders.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** Set the initial understood/not understood state of the headers in this * object */ private void initHeaderUnderstanding() { SOAPHeader soapHeader = ensureSOAPHeader(); if (soapHeader == null) { return; } Iterator allHeaders = soapHeader.examineAllHeaderElements(); while(allHeaders.hasNext()) { SOAPHeaderElement nextHdrElem = (SOAPHeaderElement) allHeaders.next(); if (nextHdrElem == null) { continue; } if (nextHdrElem.getMustUnderstand()) { notUnderstood(nextHdrElem.getElementQName()); } //only headers explicitly marked as understood should be //in the understoodHeaders set, so don't add anything to //that set at the beginning } }
Example #3
Source File: StreamHeader.java From openjdk-8-source 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. TransformerFactory tf = XmlUtil.newTransformerFactory(); Transformer t = tf.newTransformer(); XMLStreamBufferSource source = new XMLStreamBufferSource(_mark); DOMResult result = new DOMResult(); t.transform(source, result); Node d = result.getNode(); if(d.getNodeType() == Node.DOCUMENT_NODE) d = d.getFirstChild(); SOAPHeader header = saaj.getSOAPHeader(); if(header == null) header = saaj.getSOAPPart().getEnvelope().addHeader(); Node node = header.getOwnerDocument().importNode(d, true); header.appendChild(node); } catch (Exception e) { throw new SOAPException(e); } }
Example #4
Source File: SoapServlet.java From mdw with Apache License 2.0 | 6 votes |
protected Map<String,String> addSoapMetaInfo(Map<String, String> metaInfo, SOAPMessage soapMessage) throws SOAPException { SOAPHeader soapHeader = soapMessage.getSOAPHeader(); if (soapHeader == null) { return metaInfo; } else { Map<String, String> newMetaInfo = new HashMap<String, String>(); newMetaInfo.putAll(metaInfo); Iterator<?> iter = soapHeader.examineAllHeaderElements(); while (iter.hasNext()) { SOAPHeaderElement headerElem = (SOAPHeaderElement) iter.next(); if (!Listener.AUTHENTICATED_USER_HEADER.equals(headerElem.getNodeName())) newMetaInfo.put(headerElem.getNodeName(), headerElem.getTextContent()); } return newMetaInfo; } }
Example #5
Source File: TraceeServerHandler.java From tracee with BSD 3-Clause "New" or "Revised" License | 6 votes |
protected final void handleIncoming(SOAPMessageContext context) { final SOAPMessage soapMessage = context.getMessage(); try { final SOAPHeader header = soapMessage.getSOAPHeader(); if (header != null && traceeBackend.getConfiguration().shouldProcessContext(IncomingRequest)) { final Map<String, String> parsedContext = transportSerialization.parseSoapHeader(header); final Map<String, String> filteredContext = traceeBackend.getConfiguration().filterDeniedParams(parsedContext, IncomingRequest); traceeBackend.putAll(filteredContext); } } catch (final SOAPException e) { logger.warn("Error during precessing of inbound soap header: {}", e.getMessage()); logger.debug("Detailed: Error during precessing of inbound soap header: {}", e.getMessage(), e); } Utilities.generateInvocationIdIfNecessary(traceeBackend); }
Example #6
Source File: LoggingHandler.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
private void getMessageID(SOAPMessage msg) throws SOAPException { SOAPHeader header = msg.getSOAPHeader(); if (header != null && header.getChildElements().hasNext()) { Node elementsResponseHeader = (Node)header.getChildElements().next(); NodeList elementsheader = elementsResponseHeader.getChildNodes(); for(int i = 0; i < elementsheader.getLength(); ++i) { org.w3c.dom.Node element = elementsheader.item(i); if (element.getLocalName() != null && element.getLocalName().equals("MessageID")) { LOG.info("The message id of the response: " + element.getNodeValue()); break; } } } }
Example #7
Source File: EPRHeader.java From openjdk-8-source 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 #8
Source File: MustUnderstandHandler.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
public boolean handleMessage(SOAPMessageContext cxt) { Boolean outbound = (Boolean) cxt.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outbound) { SOAPMessage message = cxt.getMessage(); try { SOAPHeader header = message.getSOAPHeader(); if(header != null) { Iterator<SOAPElement> it = header.getChildElements(WSSE); while(it.hasNext()) { SOAPElement el = (SOAPElement)it.next(); el.removeAttributeNS(message.getSOAPPart().getEnvelope().getNamespaceURI(), "mustUnderstand"); LOG.debug("Recipe hook: The mustunderstand in security header has succesfully been removed"); } message.saveChanges(); } } catch (SOAPException e) { throw SecurableSoapMessage.newSOAPFaultException("Recipe hook problem: " + e.getMessage(), e); } } return true; }
Example #9
Source File: OutboundReferenceParameterHeader.java From openjdk-jdk8u-backup 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 #10
Source File: WsAddressingHandlerV200508.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
public boolean handleOutbound(SOAPMessageContext context) { Boolean wsAddressingUse = context.get("org.taktik.connector.technical.handler.WsAddressingHandlerV200508.use") == null ? Boolean.FALSE : (Boolean)context.get("org.taktik.connector.technical.handler.WsAddressingHandlerV200508.use"); if (wsAddressingUse) { try { WsAddressingHeader header = (WsAddressingHeader)context.get("org.taktik.connector.technical.handler.WsAddressingHandlerV200508"); if (header == null) { LOG.warn("No WsAddressingHeader in the requestMap. Skipping the WsAddressingHandler."); return true; } SOAPHeader soapHeader = getSOAPHeader(context); this.processRequiredElements(header, soapHeader); this.processOptionalElements(header, soapHeader); context.getMessage().saveChanges(); } catch (SOAPException var5) { LOG.error("Error while generating WS-Addressing header", var5); } } else { LOG.warn("WsAddressingHandler is configured but org.taktik.connector.technical.handler.WsAddressingHandlerV200508.useproperty was not present or set to FALSE."); } return true; }
Example #11
Source File: SoapRequestParserTest.java From development with Apache License 2.0 | 6 votes |
@Test public void parseApiVersion_ctmg_1_8() throws Exception { // given SOAPPart part = mock(SOAPPart.class); SOAPEnvelope envelope = mock(SOAPEnvelope.class); SOAPHeader soapHeader = mock(SOAPHeader.class); List<Node> version = new ArrayList<Node>(); Node node = mock(Node.class); doReturn("testVersion").when(node).getValue(); version.add(node); Iterator<?> it = version.iterator(); doReturn(it).when(soapHeader).extractHeaderElements( eq("ctmg.service.version")); doReturn(soapHeader).when(envelope).getHeader(); doReturn(envelope).when(part).getEnvelope(); doReturn(part).when(message).getSOAPPart(); // when String result = SoapRequestParser.parseApiVersion(context); // then assertEquals("testVersion", result); }
Example #12
Source File: WsAddressingHandlerV200508.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
public boolean handleOutbound(SOAPMessageContext context) { Boolean wsAddressingUse = context.get("be.ehealth.technicalconnector.handler.WsAddressingHandlerV200508.use") == null ? Boolean.FALSE : (Boolean)context.get("be.ehealth.technicalconnector.handler.WsAddressingHandlerV200508.use"); if (wsAddressingUse.booleanValue()) { try { WsAddressingHeader header = (WsAddressingHeader)context.get("be.ehealth.technicalconnector.handler.WsAddressingHandlerV200508"); if (header == null) { LOG.warn("No WsAddressingHeader in the requestMap. Skipping the WsAddressingHandler."); return true; } SOAPHeader soapHeader = getSOAPHeader(context); this.processRequiredElements(header, soapHeader); this.processOptionalElements(header, soapHeader); context.getMessage().saveChanges(); } catch (SOAPException var5) { LOG.error("Error while generating WS-Addressing header", var5); } } else { LOG.warn("WsAddressingHandler is configured but be.ehealth.technicalconnector.handler.WsAddressingHandlerV200508.useproperty was not present or set to FALSE."); } return true; }
Example #13
Source File: MustUnderstandHandler.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
public boolean handleMessage(SOAPMessageContext cxt) { Boolean outbound = (Boolean)cxt.get("javax.xml.ws.handler.message.outbound"); if (outbound.booleanValue()) { SOAPMessage message = cxt.getMessage(); try { SOAPHeader header = message.getSOAPHeader(); if (header != null) { Iterator it = header.getChildElements(WSSE); while(it.hasNext()) { SOAPElement el = (SOAPElement)it.next(); el.removeAttributeNS(message.getSOAPPart().getEnvelope().getNamespaceURI(), "mustUnderstand"); LOG.debug("Recipe hook: The mustunderstand in security header has succesfully been removed"); } message.saveChanges(); } } catch (SOAPException var7) { throw SecurableSoapMessage.newSOAPFaultException("Recipe hook problem: " + var7.getMessage(), var7); } } return true; }
Example #14
Source File: SAAJMessageHeaders.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** Set the initial understood/not understood state of the headers in this * object */ private void initHeaderUnderstanding() { SOAPHeader soapHeader = ensureSOAPHeader(); if (soapHeader == null) { return; } Iterator allHeaders = soapHeader.examineAllHeaderElements(); while(allHeaders.hasNext()) { SOAPHeaderElement nextHdrElem = (SOAPHeaderElement) allHeaders.next(); if (nextHdrElem == null) { continue; } if (nextHdrElem.getMustUnderstand()) { notUnderstood(nextHdrElem.getElementQName()); } //only headers explicitly marked as understood should be //in the understoodHeaders set, so don't add anything to //that set at the beginning } }
Example #15
Source File: SOAPMessageContextImpl.java From cxf with Apache License 2.0 | 6 votes |
public Object[] getHeaders(QName name, JAXBContext context, boolean allRoles) { SOAPMessage msg = getMessage(); SOAPHeader header; try { header = msg.getSOAPPart().getEnvelope().getHeader(); if (header == null || !header.hasChildNodes()) { return new Object[0]; } List<Object> ret = new ArrayList<>(); Iterator<SOAPHeaderElement> it = CastUtils.cast(header.examineAllHeaderElements()); while (it.hasNext()) { SOAPHeaderElement she = it.next(); if ((allRoles || roles.contains(she.getActor())) && name.equals(she.getElementQName())) { ret.add(JAXBUtils.unmarshall(context, she)); } } return ret.toArray(new Object[0]); } catch (SOAPException | JAXBException e) { throw new WebServiceException(e); } }
Example #16
Source File: SoapPayloadIOTest.java From apiman with Apache License 2.0 | 6 votes |
/** * Test method for {@link io.apiman.gateway.engine.io.SoapPayloadIO#marshall(org.w3c.dom.Document)}. */ @Test public void testMarshall_Simple() throws Exception { MessageFactory msgFactory = MessageFactory.newInstance(); SOAPMessage message = msgFactory.createMessage(); SOAPEnvelope envelope = message.getSOAPPart().getEnvelope(); SOAPHeader header = envelope.getHeader(); SOAPHeaderElement cheader = header.addHeaderElement(new QName("urn:ns1", "CustomHeader")); cheader.setTextContent("CVALUE"); SoapPayloadIO io = new SoapPayloadIO(); byte[] data = io.marshall(envelope); String actual = new String(data); String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"><SOAP-ENV:Header><CustomHeader xmlns=\"urn:ns1\">CVALUE</CustomHeader></SOAP-ENV:Header><SOAP-ENV:Body/></SOAP-ENV:Envelope>"; Assert.assertEquals(expected, actual); }
Example #17
Source File: OutboundReferenceParameterHeader.java From jdk8u60 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 #18
Source File: JaxWsSoapContextHandler.java From googleads-java-lib with Apache License 2.0 | 6 votes |
/** * Captures pertinent information from SOAP messages exchanged by the SOAP * service this handler is attached to. Also responsible for placing custom * (implicit) SOAP headers on outgoing messages. * * @see SOAPHandler#handleMessage(MessageContext) * @param context the context of the SOAP message passing through this handler * @return whether this SOAP interaction should continue */ @Override public boolean handleMessage(SOAPMessageContext context) { if ((Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY)) { // Outbound message (request), so reset the last request and response builders. lastRequestInfo = new RequestInfo.Builder(); lastResponseInfo = new ResponseInfo.Builder(); SOAPMessage soapMessage = context.getMessage(); try { SOAPHeader soapHeader = soapMessage.getSOAPHeader(); if (soapHeader == null) { soapHeader = soapMessage.getSOAPPart().getEnvelope().addHeader(); } for (SOAPElement header : soapHeaders) { soapHeader.addChildElement(header); } } catch (SOAPException e) { throw new ServiceException("Error setting SOAP headers on outbound message.", e); } captureServiceAndOperationNames(context); } captureSoapXml(context); return true; }
Example #19
Source File: SAAJMessageHeaders.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Override public List<Header> asList() { SOAPHeader soapHeader = ensureSOAPHeader(); if (soapHeader == null) { return Collections.emptyList(); } Iterator allHeaders = soapHeader.examineAllHeaderElements(); List<Header> headers = new ArrayList<Header>(); while (allHeaders.hasNext()) { SOAPHeaderElement nextHdr = (SOAPHeaderElement) allHeaders.next(); headers.add(new SAAJHeader(nextHdr)); } return headers; }
Example #20
Source File: SAAJMessageHeaders.java From hottub with GNU General Public License v2.0 | 5 votes |
@Override public List<Header> asList() { SOAPHeader soapHeader = ensureSOAPHeader(); if (soapHeader == null) { return Collections.emptyList(); } Iterator allHeaders = soapHeader.examineAllHeaderElements(); List<Header> headers = new ArrayList<Header>(); while (allHeaders.hasNext()) { SOAPHeaderElement nextHdr = (SOAPHeaderElement) allHeaders.next(); headers.add(new SAAJHeader(nextHdr)); } return headers; }
Example #21
Source File: SOAPHeaderLoggerHandler.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
public boolean handleMessage(SOAPMessageContext ctx) { try { SOAPHeader header = ctx.getMessage().getSOAPHeader(); if (header != null) { Iterator it = ctx.getMessage().getSOAPHeader().examineAllHeaderElements(); while(it.hasNext()) { Object obj = it.next(); if (obj instanceof Element) { Element el = (Element)obj; String nameValue = "{" + el.getNamespaceURI() + "}" + el.getLocalName(); if (this.propList.contains(nameValue)) { LOG.info(ConnectorXmlUtils.toString((Source)(new DOMSource(el)))); } } else { LOG.error("Unsupported Object with name: [" + obj.getClass().getName() + "]"); } } } } catch (SOAPException var7) { LOG.error("SOAPException: " + var7.getMessage(), var7); } catch (TechnicalConnectorException var8) { LOG.error("TechnicalConnectorException: " + var8.getMessage(), var8); } return true; }
Example #22
Source File: Tr064Comm.java From openhab1-addons with Eclipse Public License 2.0 | 5 votes |
/** * Sets all required namespaces and prepares the SOAP message to send. * Creates skeleton + body data. * * @param bodyData * is attached to skeleton to form entire SOAP message * @return ready to send SOAP message */ private SOAPMessage constructTr064Msg(SOAPBodyElement bodyData) { SOAPMessage soapMsg = null; try { MessageFactory msgFac; msgFac = MessageFactory.newInstance(); soapMsg = msgFac.createMessage(); soapMsg.setProperty(SOAPMessage.WRITE_XML_DECLARATION, "true"); soapMsg.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, "UTF-8"); SOAPPart part = soapMsg.getSOAPPart(); // valid for entire SOAP msg String namespace = "s"; // create suitable fbox envelope SOAPEnvelope envelope = part.getEnvelope(); envelope.setPrefix(namespace); envelope.removeNamespaceDeclaration("SOAP-ENV"); // delete standard namespace which was already set envelope.addNamespaceDeclaration(namespace, "http://schemas.xmlsoap.org/soap/envelope/"); Name nEncoding = envelope.createName("encodingStyle", namespace, "http://schemas.xmlsoap.org/soap/encoding/"); envelope.addAttribute(nEncoding, "http://schemas.xmlsoap.org/soap/encoding/"); // create empty header SOAPHeader header = envelope.getHeader(); header.setPrefix(namespace); // create body with command based on parameter SOAPBody body = envelope.getBody(); body.setPrefix(namespace); body.addChildElement(bodyData); // bodyData already prepared. Needs only be added } catch (Exception e) { logger.error("Error creating SOAP message for fbox request with data {}", bodyData); e.printStackTrace(); } return soapMsg; }
Example #23
Source File: SAAJMessageHeaders.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override public boolean hasHeaders() { SOAPHeader soapHeader = ensureSOAPHeader(); if (soapHeader == null) { return false; } Iterator allHeaders = soapHeader.examineAllHeaderElements(); return allHeaders.hasNext(); }
Example #24
Source File: DOMHeader.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(); Node clone = header.getOwnerDocument().importNode(node,true); header.appendChild(clone); }
Example #25
Source File: SoapHeaderTransportTest.java From tracee with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void renderTpicHeaderToSoapMessage() throws SOAPException { final Map<String, String> context = Collections.singletonMap("FOO", "BAR"); final SOAPHeader soapHeader = soapMessage.getSOAPHeader(); unit.renderSoapHeader(context, soapHeader); final Iterator soapHeaders = soapHeader.getChildElements(TraceeConstants.SOAP_HEADER_QNAME); final Element tpicHeader = (Element) soapHeaders.next(); assertThat(tpicHeader.getLocalName(), is(TraceeConstants.TPIC_HEADER)); assertThat(tpicHeader.getNamespaceURI(), is(TraceeConstants.SOAP_HEADER_NAMESPACE)); assertThat(tpicHeader.getFirstChild().getLocalName(), is("entry")); assertThat(tpicHeader.getFirstChild().getAttributes().getNamedItem("key").getNodeValue(), is("FOO")); assertThat(tpicHeader.getFirstChild().getFirstChild().getNodeValue(), is("BAR")); }
Example #26
Source File: WsAddressingHandlerV200508.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
private void generateRelateToElement(SOAPHeader soapHeader, WsAddressingRelatesTo relateTo) throws SOAPException { SOAPElement relateToElement = soapHeader.addChildElement(RELATESTO); if (relateTo.getRelationshipType() != null && !relateTo.getRelationshipType().isEmpty()) { relateToElement.addAttribute(RELATIONSHIPTYPE, relateTo.getRelationshipType()); } if (relateTo.getRelationshipType() != null) { relateToElement.setTextContent(relateTo.getReleatesTo().toString()); } }
Example #27
Source File: WsAddressingHandlerV200508.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
private void processOptionalElements(WsAddressingHeader header, SOAPHeader soapHeader) throws SOAPException { if (header.getTo() != null) { soapHeader.addChildElement(TO).setTextContent(header.getTo().toString()); } if (header.getMessageID() != null) { soapHeader.addChildElement(MESSAGEID).setTextContent(header.getMessageID().toString()); } Iterator i$ = header.getRelatesTo().iterator(); while(i$.hasNext()) { WsAddressingRelatesTo relateTo = (WsAddressingRelatesTo)i$.next(); this.generateRelateToElement(soapHeader, relateTo); } if (header.getFrom() != null && !header.getFrom().isEmpty()) { soapHeader.addChildElement(FROM).setTextContent(header.getFrom().toString()); } if (header.getReplyTo() != null && !header.getReplyTo().isEmpty()) { soapHeader.addChildElement(REPLYTO).addChildElement(ADDRESS).setTextContent(header.getReplyTo().toString()); } if (header.getFaultTo() != null && !header.getFaultTo().isEmpty()) { soapHeader.addChildElement(FAULTTO).addChildElement(ADDRESS).setTextContent(header.getFaultTo().toString()); } }
Example #28
Source File: TestMustUnderstandHandler.java From cxf with Apache License 2.0 | 5 votes |
public boolean handleMessage(SOAPMessageContext ctx) { boolean continueProcessing = true; try { Object b = ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); boolean outbound = (Boolean)b; SOAPMessage msg = ctx.getMessage(); if (isServerSideHandler()) { if (outbound) { QName qname = new QName("http://cxf.apache.org/mu", "MU"); SOAPPart soapPart = msg.getSOAPPart(); SOAPEnvelope envelope = soapPart.getEnvelope(); SOAPHeader header = envelope.getHeader(); if (header == null) { header = envelope.addHeader(); } SOAPHeaderElement headerElement = header.addHeaderElement(envelope.createName("MU", "ns1", qname.getNamespaceURI())); // QName soapMustUnderstand = new QName("http://schemas.xmlsoap.org/soap/envelope/", // "mustUnderstand"); Name name = SOAPFactory.newInstance() .createName("mustUnderstand", "soap", "http://schemas.xmlsoap.org/soap/envelope/"); headerElement.addAttribute(name, "1"); } else { getHandlerInfoList(ctx).add(getHandlerId()); } } } catch (SOAPException e) { e.printStackTrace(); } return continueProcessing; }
Example #29
Source File: SAAJMessageHeaders.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private SOAPHeaderElement find(String nsUri, String localName) { SOAPHeader soapHeader = ensureSOAPHeader(); if (soapHeader == null) { return null; } Iterator allHeaders = soapHeader.examineAllHeaderElements(); while(allHeaders.hasNext()) { SOAPHeaderElement nextHdrElem = (SOAPHeaderElement) allHeaders.next(); if (nextHdrElem.getNamespaceURI().equals(nsUri) && nextHdrElem.getLocalName().equals(localName)) { return nextHdrElem; } } return null; }
Example #30
Source File: OutboundStreamHeader.java From openjdk-jdk8u 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); } }