javax.xml.soap.Node类的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(137)

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

Node介绍

[英]A representation of a node (element) in an XML document. This interface extnends the standard DOM Node interface with methods for getting and setting the value of a node, for getting and setting the parent of a node, and for removing a node.
[中]XML文档中节点(元素)的表示形式。该接口扩展了标准DOM节点接口,提供了获取和设置节点值、获取和设置节点父节点以及移除节点的方法。

代码示例

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

while (it.hasNext()) {
  value = element.getValue();

代码示例来源:origin: org.jboss.ws.native/jbossws-native-core

/**
* Detaches all children of this SOAPElement.
* <p/>
* This method is useful for rolling back the construction of partially completed SOAPHeaders and SOAPBodys in
* preparation for sending a fault when an error condition is detected.
* It is also useful for recycling portions of a document within a SOAP message.
*/
public void removeContents()
{
 Iterator<org.w3c.dom.Node> it = getChildElements();
 while (it.hasNext())
 {
   Node el = (Node)it.next();
   el.detachNode();
 }
}

代码示例来源:origin: apache/servicemix-bundles

private Node getValueNodeStrict(SOAPElement element) {
  Node node = (Node)element.getFirstChild();
  if (node != null) {
    if (node.getNextSibling() == null
      && node.getNodeType() == org.w3c.dom.Node.TEXT_NODE) {
      return node;
    } else {
      return null;
    }
  }
  return null;
}

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

/**
 * Removes all child elements from the specified
 * {@link javax.xml.soap.SOAPElement}.
 *
 * @param soapElem Element to strip
 */
protected static void removeAllChildElements(SOAPElement soapElem) {
 Iterator<?> iter = soapElem.getChildElements();
 // NOTE: Convert iterator to list to avoid ConcurrentModificationExceptions
 // caused by modifying items in an iterator during iteration
 List<?> children = toList(iter);
 for (int i = 0; i < children.size(); i++) {
  Node child = (Node) children.get(i);
  if (child.getParentElement() != null) {
   child.detachNode();
   child.recycleNode();
  }
 }
}

代码示例来源:origin: org.n52.sensorweb.sos/binding-soap

while (iter.hasNext()) {
  Node node = (Node) iter.next();
  if (node.getLocalName() != null && node.getLocalName().equals(WsaConstants.EN_ADDRESS)) {
    wsaHeaders.add(new WsaReplyToHeader(node.getValue()));
    replyTo = true;

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

SOAPMessage message = MessageFactory.newInstance().createMessage();
SOAPHeader header = message.getSOAPHeader();
header.detachNode();
SOAPElement returnElement = (SOAPElement)responseElement.getChildElements().next();
if(responseBody.getFault()!=null){
  System.out.println(returnElement.getValue()+" "+responseBody.getFault().getFaultString());
} else {
  System.out.println(returnElement.getValue());

代码示例来源:origin: com.hynnet/xws-security

if (node.getNodeType() != Node.ELEMENT_NODE) {
  continue;
if (authorityBinding == node.getLocalName() || authorityBinding.equals(node.getLocalName())) {
  try {
    if (MessageConstants.debug) {

代码示例来源:origin: com.hynnet/xws-security

public SOAPElement getFirstChildElement() {
  Iterator eachChild = getChildElements();
  javax.xml.soap.Node node = null;
  if (eachChild.hasNext()) {
    node = (javax.xml.soap.Node) eachChild.next();
  }else {
    return null;
  }
  while ((node.getNodeType() != Node.ELEMENT_NODE) && eachChild.hasNext()) {
    node = (javax.xml.soap.Node) eachChild.next();
  }
  if ((null != node) /*&& (node.getNodeType() == Node.ELEMENT_NODE)*/)
    return (SOAPElement) node;
  else
    return null;
}

代码示例来源:origin: org.n52.svalbard/svalbard-xmlbeans

while (iter.hasNext()) {
  Node node = (Node) iter.next();
  if (node.getLocalName() != null && node.getLocalName().equals(WsaConstants.EN_ADDRESS)) {
    wsaHeaders.add(new WsaReplyToHeader(node.getValue()));
    replyTo = true;

代码示例来源:origin: com.hynnet/xws-security

/**
 * Takes a SOAPElement and checks if it has the right name and structure.
 */
public EmbeddedReference(SOAPElement element) throws XWSSecurityException {
  setSOAPElement(element);
  if (!(element.getLocalName().equals("Embedded") &&
     XMLUtil.inWsseNS(element))) {
    log.log(Level.SEVERE,
        "WSS0752.invalid.embedded.reference");
    throw new XWSSecurityException("Invalid EmbeddedReference passed");
  }
  Iterator eachChild = getChildElements();
  Node node = null;
  while (!(node instanceof SOAPElement) && eachChild.hasNext()) {
    node = (Node) eachChild.next();
  }
  if ((node != null) && (node.getNodeType() == Node.ELEMENT_NODE)) {
    embeddedElement  = (SOAPElement) node;
  } else {
    log.log(Level.SEVERE,
        "WSS0753.missing.embedded.token");
    throw new XWSSecurityException(
      "Passed EmbeddedReference does not contain an embedded element");
  }
}

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

/**
 * Get the WS-A MessageID from the envelope.
 *
 * @param soapEnvelope The SOAPEnvelope
 * @return The message id if found, null otehrwise
 * @throws SOAPException If the envelope could not be read
 */
public static String getMessageID(SOAPEnvelope soapEnvelope) throws SOAPException {
  NodeList headers = soapEnvelope.getHeader().getElementsByTagNameNS(WSA_ACTION_QNAME.getNamespaceURI(), WSA_ACTION_QNAME.getLocalPart());
  if (headers.getLength() == 1) {
    return ((javax.xml.soap.Node)headers.item(0)).getValue();
  }
  return null;
}

代码示例来源:origin: org.springframework.ws/spring-ws-core

@SuppressWarnings("unchecked")
@Override
public void removeHeaderElement(QName name) throws SoapHeaderException {
  Iterator<Node> iterator = getSaajHeader().getChildElements(name);
  if (iterator.hasNext()) {
    Node element = iterator.next();
    element.detachNode();
  }
}

代码示例来源:origin: jboss-switchyard/components

/**
 * Get the WS-A MessageID from the envelope.
 *
 * @param soapEnvelope The SOAPEnvelope
 * @return The message id if found, null otehrwise
 * @throws SOAPException If the envelope could not be read
 */
public static String getMessageID(SOAPEnvelope soapEnvelope) throws SOAPException {
  NodeList headers = soapEnvelope.getHeader().getElementsByTagNameNS(WSA_ACTION_QNAME.getNamespaceURI(), WSA_ACTION_QNAME.getLocalPart());
  if (headers.getLength() == 1) {
    return ((javax.xml.soap.Node)headers.item(0)).getValue();
  }
  return null;
}

代码示例来源:origin: spring-projects/spring-ws

@SuppressWarnings("unchecked")
@Override
public void removeHeaderElement(QName name) throws SoapHeaderException {
  Iterator<Node> iterator = getSaajHeader().getChildElements(name);
  if (iterator.hasNext()) {
    Node element = iterator.next();
    element.detachNode();
  }
}

代码示例来源:origin: se.skltp.mb/mb-intsvc

private String extractTargetOrg(SOAPMessage soapMessage) throws SOAPException {
  // rivta2.0 uses To, 2.1 uses LogicalAddress
  Iterator iter = soapMessage.getSOAPHeader().getChildElements(TO_QNAME);
  if (!iter.hasNext()) {
    iter = soapMessage.getSOAPHeader().getChildElements(LOGICAL_ADDRESS_QNAME);
  }
  if (!iter.hasNext()) {
    throw new RuntimeException("No address node found in header!");
  }
  return ((Node)iter.next()).getValue();
}

代码示例来源:origin: apache/servicemix-bundles

@SuppressWarnings("unchecked")
@Override
public void removeHeaderElement(QName name) throws SoapHeaderException {
  Iterator<Node> iterator = getSaajHeader().getChildElements(name);
  if (iterator.hasNext()) {
    Node element = iterator.next();
    element.detachNode();
  }
}

代码示例来源:origin: se.skltp.mb/mb-modules-intsvc

private String extractTargetOrg(SOAPMessage soapMessage) throws SOAPException {
  // rivta2.0 uses To, 2.1 uses LogicalAddress
  Iterator iter = soapMessage.getSOAPHeader().getChildElements(TO_QNAME);
  if ( !iter.hasNext() ) {
    iter = soapMessage.getSOAPHeader().getChildElements(LOGICAL_ADDRESS_QNAME);
  }
  if ( !iter.hasNext() ) {
    throw new RuntimeException("No address node found in header!");
  }
  return ((Node) iter.next()).getValue();
}

代码示例来源:origin: apache/servicemix-bundles

firstBodyElement.detachNode();

代码示例来源:origin: gooddata/GoodData-CL

/**
 * Logs into the MS CRM 2011 Online
 *
 * @return the Live ID token
 * @throws JaxenException issue with the response format
 * @throws IOException    generic IO issue
 * @throws SOAPException  issue with SOAP invocation
 */
public String login() throws IOException, SOAPException, JaxenException {
  String msg = FileUtil.readStringFromClasspath("/com/gooddata/msdynamics/LiveIdLogin.xml", MsDynamicsWrapper.class);
  msg = msg.replaceAll(LIVE_ID_SERVER_PLACEHOLDER, getHost());
  msg = msg.replaceAll(LIVE_ID_USERNAME_PLACEHOLDER, getUsername());
  msg = msg.replaceAll(LIVE_ID_PASSWORD_PLACEHOLDER, getPassword());
  msg = msg.replaceAll(LIVE_ID_POLICY_PLACEHOLDER, getPolicy());
  SOAPMessage response = soap.execute(HTTPS + LIVE_ID_HOST + LIVE_ID_ENDPOINT, msg);
  XPath xp = soap.createXPath("//wsse:BinarySecurityToken/text()", response);
  xp.addNamespace("wsse", WSSE_XMLNS);
  Node result = (Node) xp.selectSingleNode(response.getSOAPBody());
  return result.getValue();
}

代码示例来源:origin: apache/axis2-java

Node childSAAJNode = toSAAJNode(childNodes.item(i), saajEle);
if (childSAAJNode instanceof javax.xml.soap.Text) {
  saajEle.addTextNode(childSAAJNode.getValue());
} else {
  saajEle.addChildElement((javax.xml.soap.SOAPElement)childSAAJNode);

相关文章

微信公众号

最新文章

更多