final SOAPElement security = header.addChildElement("Security", "wsse", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"); final SOAPElement userToken = security.addChildElement("UsernameToken", "wsse");
SOAPHeader header = context.getMessage().getSOAPPart().getEnvelope().addHeader(); header.addChildElement(securitySOAPElement);
private String addMessageID(SOAPHeader header) throws HeaderProcessingException { try { String id = null; if (fProperties.containsKey(WSA_TAG_MESSAGE_ID)) { id = fProperties.get(WSA_TAG_MESSAGE_ID); } else { id = WSA_MESSAGE_ID_PREFIX + UUID.randomUUID().toString(); } SOAPElement msgId = header.addChildElement(wsaQName(WSA_TAG_MESSAGE_ID)); msgId.setTextContent(id); return id; } catch (SOAPException e) { throw new HeaderProcessingException( "Could not add MessageID header to outgoing SOAP message.", e); } }
@Override public boolean handleMessage(SOAPMessageContext smc) { if (isOutgoingMessage(smc)) { try { SOAPHeader header = getSOAPHeader(smc); SOAPElement vcsessionHeader = header.addChildElement(new javax.xml.namespace.QName("#", "vcSessionCookie")); vcsessionHeader.setValue(this.vcSessionCookie); } catch (DOMException e) { throw new RuntimeException(e); } catch (SOAPException e) { throw new RuntimeException(e); } } return true; }
/** * Add child element to header. * * @param naam the naam * @param prefix the prefix * @param namespaceUri the namespace uri * @param value the value * @throws SOAPException the soap exception */ public void addChildElementToHeader(String naam, String prefix, String namespaceUri, String value) throws SOAPException { SOAPHeader header = soapMessage.getSOAPHeader(); SOAPElement headerElement = header.addChildElement(naam, prefix, namespaceUri); if (!attributes.isEmpty()) { for (HashMap.Entry<QName, String> entry : attributes.entrySet()) { headerElement.addAttribute(entry.getKey(), entry.getValue()); } } //clear the attributes HashMap after they have been used clearAttributes(); if (value.length() > 0) { headerElement.addTextNode(value); } this.elements.put(naam, headerElement); }
private void addRelatesToHeader(SOAPHeader header, String messageID) throws HeaderProcessingException { SOAPElement msgId; try { msgId = header.addChildElement(wsaQName(WSA_TAG_RELATES_TO)); } catch (SOAPException e) { throw new HeaderProcessingException( "Could not add RelatesTo header to outgoing SOAP message.", e); } msgId.setTextContent(messageID); }
@Override public boolean add(RpcHeader e) { try { header.addChildElement(e.getName(), "ns", e.getNamespace()).setValue(e.getValue()); } catch (SOAPException e1) { throw new RuntimeException(e1); } return true; }
final SOAPElement aSOAPElement = aSoapHeader.addChildElement (new QName (aRefParamElement.getNamespaceURI (), aRefParamElement.getLocalName ())); aSOAPElement.setTextContent (aRefParamElement.getTextContent ());
private void copyToSOAPHeader(SOAPHeader soapHeader, Property property) throws IOException, SOAPException { if ((property != null) && (matches(property.getName(), getIncludeRegexes(), new ArrayList<Pattern>()))) { String v = property.getValue().toString(); QName qname = new QName(HEADER_NAMESPACE_PROPAGATION, property.getName()); if (SOAPHeadersType.XML.equals(_soapHeadersType)) { try { Element xmlElement = new ElementPuller().pull(new StringReader(v)); Node xmlNode = soapHeader.getOwnerDocument().importNode(xmlElement, true); soapHeader.appendChild(xmlNode); } catch (Throwable t) { soapHeader.addChildElement(qname).setValue(v); } } else { soapHeader.addChildElement(qname).setValue(v); } } } }
Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if(outboundProperty.booleanValue()) { try { SOAPHeader header = context.getMessage().getSOAPPart().getEnvelope().getHeader(); SOAPFactory soapFactory = SOAPFactory.newInstance(); SOAPElement authnHeader = soapFactory.createElement("authnHeader", "ns", "http://webservices.averittexpress.com/authn"); SOAPElement username = authnHeader.addChildElement("Username"); username.setTextContent("xxxxxxx"); SOAPElement password = authnHeader.addChildElement("Password"); password.setTextContent("xxxxxxx"); header.addChildElement(authnHeader); } catch(Exception e) { e.printStackTrace(); } }
/** * Serialize the reference properties/parameters in the SOAP Header. * * @param env Envelope to modify * @param refPs List of reference properties * @param actorURI Actor URI * @param addAttribute Whether to mark elements as reference properties (W3C version) */ private void serializeReferencePs(SOAPEnvelope env, List<MessageElement> refPs, String actorURI, boolean addAttribute) throws SOAPException { // If no referenceProps are available, we are done if (refPs == null || refPs.size() == 0) { return; } SOAPHeaderElement element; SOAPHeader header = env.getHeader(); if (header == null) { header = env.addHeader(); } // Add each ref property to SOAP Header for (MessageElement refProp : refPs) { element = this.makeSOAPHeader(refProp); element.setActor(actorURI); // If we're supposed to mark this as a refP, do so (W3C version) if (addAttribute) { element.addAttribute(Constants.ATTR_REFP, "true"); } header.addChildElement(element); } }
public boolean handleMessage(MessageContext context) { SOAPMessageContext smc = (SOAPMessageContext) context; Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outboundProperty.booleanValue() && sessionId != null) { SOAPMessage message = smc.getMessage(); try { SOAPEnvelope envelope = message.getSOAPPart().getEnvelope(); SOAPHeader header = envelope.getHeader(); if (header == null) { header = envelope.addHeader(); } String WSSE_NS = "http://www.informatica.com/wsh/"; String WSSE_PREFIX = "infa"; SOAPElement scontext = header.addChildElement("Context", WSSE_PREFIX, WSSE_NS); SOAPElement sessionElemeent = scontext.addChildElement("SessionId"); sessionElemeent.addTextNode(sessionId); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } } return outboundProperty; }
private void addReplyTo(SOAPHeader header, ActivityContext context) throws HeaderProcessingException { try { SOAPElement replyTo = header.addChildElement(wsaQName(WSA_TAG_REPLY_TO)); SOAPElement address = replyTo.addChildElement(wsaQName(WSA_TAG_ADDRESS)); address.setTextContent(context.getPartnerURL()); } catch (SOAPException e) { throw new HeaderProcessingException( "Could not add ReplyTo header to outgoing SOAP message.", e); } }
@Override public boolean handleMessage(SOAPMessageContext context) { // we are interested only in outbound messages here if (!(Boolean)context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY)) { return true; } if (params == null) { return true; } try { SOAPFactory factory = SOAPFactory.newInstance(); for (Object o : params.getAny()) { SOAPElement elm = factory.createElement((Element)o); context.getMessage().getSOAPHeader() .addChildElement(SOAPFactory.newInstance().createElement(elm)); } } catch (SOAPException e) { throw new RuntimeException(e); } return true; }
@Override public boolean handleMessage(SOAPMessageContext context) { // we are interested only in outbound messages here if (!(Boolean)context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY)) { return true; } if (params == null) { return true; } try { SOAPFactory factory = SOAPFactory.newInstance(); for (Object o : params.getAny()) { SOAPElement elm = factory.createElement((Element)o); context.getMessage().getSOAPHeader() .addChildElement(SOAPFactory.newInstance().createElement(elm)); } } catch (SOAPException e) { throw new RuntimeException(e); } return true; }
SOAPEnvelope envelope = smc.getMessage().getSOAPPart().getEnvelope(); SOAPFactory soapFactory = SOAPFactory.newInstance(); SOAPHeader sh = envelope.addHeader(); SOAPElement wsSecHeaderElm = soapFactory.createElement("Security", AUTH_PREFIX, AUTH_NS); SOAPElement userNameTokenElm = soapFactory.createElement("UsernameToken", AUTH_PREFIX, AUTH_NS); SOAPElement userNameElm = soapFactory.createElement("Username", AUTH_PREFIX, AUTH_NS); SOAPElement passwdElm = soapFactory.createElement("Password", AUTH_PREFIX, AUTH_NS); userNameElm.addTextNode("username"); passwdElm.addTextNode("password"); userNameTokenElm.addChildElement(userNameElm); userNameTokenElm.addChildElement(passwdElm); wsSecHeaderElm.addChildElement(userNameTokenElm); sh.addChildElement(wsSecHeaderElm);
header.addChildElement("Security", "wsse", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
soapHeader.addChildElement(header);
soapHeader.addChildElement(header);
SOAPElement element = header.addChildElement(CIDQN); element.addTextNode(conversationId); smc.getMessage().saveChanges();