javax.xml.soap.SOAPHeader.addChildElement()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(105)

本文整理了Java中javax.xml.soap.SOAPHeader.addChildElement()方法的一些代码示例,展示了SOAPHeader.addChildElement()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SOAPHeader.addChildElement()方法的具体详情如下:
包路径:javax.xml.soap.SOAPHeader
类名称:SOAPHeader
方法名:addChildElement

SOAPHeader.addChildElement介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

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");

代码示例来源:origin: stackoverflow.com

SOAPHeader header = context.getMessage().getSOAPPart().getEnvelope().addHeader();
header.addChildElement(securitySOAPElement);

代码示例来源:origin: net.bpelunit/framework

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);
  }
}

代码示例来源:origin: com.vmware.photon.controller/photon-vsphere-adapter-util

@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;
}

代码示例来源:origin: nl.psek.fitnesse/psek-fitnesse-fixtures-general

/**
 * 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);
}

代码示例来源:origin: net.bpelunit/framework

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);
}

代码示例来源:origin: net.servicegrid/jp.go.nict.langrid.commons

@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;
}

代码示例来源:origin: com.helger/peppol-lime-client

final SOAPElement aSOAPElement = aSoapHeader.addChildElement (new QName (aRefParamElement.getNamespaceURI (),
                                     aRefParamElement.getLocalName ()));
aSOAPElement.setTextContent (aRefParamElement.getTextContent ());

代码示例来源:origin: org.switchyard.components/switchyard-component-soap

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);
      }
    }
  }
}

代码示例来源:origin: stackoverflow.com

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();
  }
}

代码示例来源:origin: net.sourceforge.addressing/addressing

/**
 * 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);
 }
}

代码示例来源:origin: org.bitbucket.bradleysmithllc.webserviceshubclient/jcmd

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;
}

代码示例来源:origin: net.bpelunit/framework

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);
  }
}

代码示例来源:origin: apache/cxf

@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;
}

代码示例来源:origin: org.apache.cxf/cxf-rt-ws-eventing

@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;
}

代码示例来源:origin: stackoverflow.com

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);

代码示例来源:origin: stackoverflow.com

header.addChildElement("Security", "wsse", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");

代码示例来源:origin: googleads/googleads-java-lib

soapHeader.addChildElement(header);

代码示例来源:origin: com.google.api-ads/ads-lib-appengine

soapHeader.addChildElement(header);

代码示例来源:origin: org.jboss.seam/jboss-seam

SOAPElement element = header.addChildElement(CIDQN);
element.addTextNode(conversationId);
smc.getMessage().saveChanges();

相关文章