@Override public CompletableFuture<? extends SOAPResponse> invoke(InvocationContext context, SOAPEnvelope request, Handler<SOAPEnvelope,SOAPResponse> nextHandler) { request.getOrCreateHeader().addHeaderBlock(HEADER_NAME).setText(connectionId); return nextHandler.invoke(context, request); } }
private void addCustomHeader(MessageContext synCtx, String value) { SOAPEnvelope env = synCtx.getEnvelope(); if (env == null) { return; } SOAPFactory fac = (SOAPFactory) env.getOMFactory(); SOAPHeader header = env.getOrCreateHeader(); if (!isImplicit()) { SOAPHeaderBlock hb = header.addHeaderBlock(qName.getLocalPart(), fac.createOMNamespace(qName.getNamespaceURI(), qName.getPrefix())); hb.setText(value); } else if (hasEmbeddedXml()) { for (OMElement e : embeddedXmlContent) { // Don't attach the original OMElement here. // If another mediator down the line, changes the OM, we are in trouble. header.addChild(e.cloneOMElement()); } } }
if (node instanceof SOAPEnvelope) { SOAPEnvelope soapEnvelope = (SOAPEnvelope) node; soapEnvelope.getOrCreateHeader(); sourceNodeList.add(soapEnvelope); } else {
/** * Add a new SOAP header to the message. * * @param mustUnderstand the value for the <code>soapenv:mustUnderstand</code> attribute * @param content the XML for the new header * @throws ScriptException if an error occurs when converting the XML to OM */ public void addHeader(boolean mustUnderstand, Object content) throws ScriptException { SOAPHeader header = mc.getEnvelope().getOrCreateHeader(); OMElement element = xmlHelper.toOMElement(content); // We can't add the element directly to the SOAPHeader. Instead, we need to copy the // information over to a SOAPHeaderBlock. SOAPHeaderBlock headerBlock = header.addHeaderBlock(element.getLocalName(), element.getNamespace()); for (Iterator it = element.getAllAttributes(); it.hasNext(); ) { headerBlock.addAttribute((OMAttribute)it.next()); } headerBlock.setMustUnderstand(mustUnderstand); OMNode child = element.getFirstOMChild(); while (child != null) { // Get the next child before addChild will detach the node from its original place. OMNode next = child.getNextOMSibling(); headerBlock.addChild(child); child = next; } }
@Override public CompletableFuture<? extends SOAPResponse> invoke(InvocationContext context, SOAPEnvelope request, Handler<SOAPEnvelope,SOAPResponse> nextHandler) { Credentials credentials = context.getAttribute(Credentials.class); if (credentials != null) { SOAPFactory factory = (SOAPFactory)request.getOMFactory(); SOAPHeader header = request.getOrCreateHeader(); OMNamespace ns = factory.createOMNamespace("admin", "ns"); header.addAttribute("SecurityEnabled", "true", ns); if (credentials instanceof BasicAuthCredentials) { BasicAuthCredentials basicAuthCreds = (BasicAuthCredentials)credentials; factory.createSOAPHeaderBlock("username", null, header).setText(basicAuthCreds.getUsername()); factory.createSOAPHeaderBlock("password", null, header).setText(basicAuthCreds.getPassword()); factory.createSOAPHeaderBlock("LoginMethod", null, header).setText("BasicAuth"); } else { // TODO: proper exception throw new UnsupportedOperationException(); } } return nextHandler.invoke(context, request); } }
axisOutMsgCtx.getEnvelope().getOrCreateHeader();
messageContext.getEnvelope().getOrCreateHeader();