SOAPHeader header = envelope.getHeader(); if (header == null) header = envelope.addHeader();
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); } }
/** Returns the header of the given envelope. */ @Override public SOAPHeader getHeader(SOAPEnvelope envelope) throws SOAPException { return envelope.getHeader(); }
import javax.xml.soap.*; SOAPPart part = request.getSOAPPart(); SOAPEnvelope env = part.getEnvelope(); SOAPHeader header = env.getHeader(); if (header == null) { // Throw an exception } NodeList userIdNode = header.getElementsByTagNameNS("*", "userId"); String userId = userIdNode.item(0).getChildNodes().item(0).getNodeValue();
/** * Gets the SOAP Header contained in this <code>SOAPMessage</code> object. * * @return the <code>SOAPHeader</code> object contained by this <code>SOAPMessage</code> object * @throws javax.xml.soap.SOAPException if the SOAP Header does not exist or cannot be * retrieved */ public SOAPHeader getSOAPHeader() throws SOAPException { return this.soapPart.getEnvelope().getHeader(); }
/** * Retrieves (and leaves in place) the secured action indormation from the SOAP envelope. * * @param envelope * @throws SOAPException */ public void examineSecuredAction(SOAPEnvelope envelope) throws SOAPException { SOAPHeader header = envelope.getHeader(); examineSecuredAction(header); }
/** * Retrieves (and leaves in place) the secured action indormation from the SOAP envelope. * * @param envelope * @throws SOAPException */ public void examineSamlTicket(SOAPEnvelope envelope, SamlTicketFactory factory) throws SOAPException { SOAPHeader header = envelope.getHeader(); examineSamlTicket(header, factory); }
/** * Retrieves (and leaves in place) the FederatedCatalogIDs indormation from the SOAP envelope. * * @param envelope * @throws SOAPException */ public void examineFederatedCatalogIDs(SOAPEnvelope envelope) throws SOAPException { SOAPHeader header = envelope.getHeader(); examineFederatedCatalogIDs(header); }
/** * Extracts (gets + removes!) the secured action information from the SOAP envelope. * * @param envelope * @throws SOAPException */ public void extractSecuredAction(SOAPEnvelope envelope) throws SOAPException { SOAPHeader header = envelope.getHeader(); extractSecuredAction(header); }
/** * Retrieves (and leaves in place) the fedCatInfos indormation from the SOAP envelope. * * @param envelope * @throws SOAPException */ //*** public void examineFedCatInfo(SOAPEnvelope envelope) throws SOAPException { SOAPHeader header = envelope.getHeader(); examineFedCatInfo(header); }
SOAPHeader getOrCreateHeader(SOAPEnvelope soapEnvelope) throws SOAPException { final SOAPHeader header = soapEnvelope.getHeader(); if (header != null) { return header; } else { return soapEnvelope.addHeader(); } }
/** * Extracts (gets + removes!) the FederatedCatalogIDs indormation from the SOAP envelope. * * @param envelope * @throws SOAPException */ public void extractFederatedCatalogIDs(SOAPEnvelope envelope) throws SOAPException { SOAPHeader header = envelope.getHeader(); extractFederatedCatalogIDs(header); }
/** * Returns the header. If not present then adds one and return the same * */ public static SOAPHeader getOrCreateSOAPHeader(SOAPMessageContext smc) throws SOAPException { SOAPEnvelope envelope = smc.getMessage().getSOAPPart().getEnvelope(); return envelope.getHeader() == null ? envelope.addHeader() : envelope.getHeader(); }
private void handleOutboundMessage(SOAPMessageContext context) throws SOAPException { SOAPMessage soapMessage = context.getMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); SOAPEnvelope soapEnvelope = soapPart.getEnvelope(); SOAPHeader header = soapEnvelope.getHeader(); NodeList toNodeList = header.getElementsByTagNameNS("http://www.w3.org/2005/08/addressing", "To"); if (toNodeList.getLength() != 0) { Element toElement = (Element) toNodeList.item(0); toElement.setTextContent(this.to); } }
public static SOAPHeader getHeader(SOAPMessage m) throws SOAPException { try { return m.getSOAPHeader(); } catch (UnsupportedOperationException ex) { return m.getSOAPPart().getEnvelope().getHeader(); } } public static SOAPBody getBody(SOAPMessage m) throws SOAPException {
public static SOAPHeader getHeader(SOAPMessage m) throws SOAPException { try { return m.getSOAPHeader(); } catch (UnsupportedOperationException ex) { return m.getSOAPPart().getEnvelope().getHeader(); } } public static SOAPBody getBody(SOAPMessage m) throws SOAPException {
private static void adjustPrefixes(SOAPEnvelope env, String envPrefix, String bodyPrefix) throws SOAPException { SAAJUtils.adjustPrefix(env, envPrefix); SAAJUtils.adjustPrefix(env.getBody(), bodyPrefix); SAAJUtils.adjustPrefix(env.getHeader(), envPrefix); }
private static void adjustPrefixes(SOAPEnvelope env, String envPrefix, String bodyPrefix) throws SOAPException { SAAJUtils.adjustPrefix(env, envPrefix); SAAJUtils.adjustPrefix(env.getBody(), bodyPrefix); SAAJUtils.adjustPrefix(env.getHeader(), envPrefix); }
/** * Returns the header. If not present then adds one and return the same */ private SOAPHeader getSOAPHeader(SOAPMessageContext smc) throws SOAPException { return smc.getMessage().getSOAPPart().getEnvelope().getHeader() == null ? smc .getMessage().getSOAPPart().getEnvelope().addHeader() : smc.getMessage().getSOAPPart().getEnvelope().getHeader(); }
SOAPPart soappart = message.getSOAPPart(); SOAPEnvelope envelope = soappart.getEnvelope(); SOAPHeader header = envelope.getHeader(); WSSecHeader wsheader = new WSSecHeader(); wsheader.insertSecurityHeader(soappart); WSSecUsernameToken token = new WSSecUsernameToken(); token.setPasswordType(WSConstants.PASSWORD_DIGEST); token.setUserInfo("myuser", "mypass"); token.build(soappart, wsheader);