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

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

本文整理了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

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

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

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

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

  1. private Node getValueNodeStrict(SOAPElement element) {
  2. Node node = (Node)element.getFirstChild();
  3. if (node != null) {
  4. if (node.getNextSibling() == null
  5. && node.getNodeType() == org.w3c.dom.Node.TEXT_NODE) {
  6. return node;
  7. } else {
  8. return null;
  9. }
  10. }
  11. return null;
  12. }

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

  1. /**
  2. * Removes all child elements from the specified
  3. * {@link javax.xml.soap.SOAPElement}.
  4. *
  5. * @param soapElem Element to strip
  6. */
  7. protected static void removeAllChildElements(SOAPElement soapElem) {
  8. Iterator<?> iter = soapElem.getChildElements();
  9. // NOTE: Convert iterator to list to avoid ConcurrentModificationExceptions
  10. // caused by modifying items in an iterator during iteration
  11. List<?> children = toList(iter);
  12. for (int i = 0; i < children.size(); i++) {
  13. Node child = (Node) children.get(i);
  14. if (child.getParentElement() != null) {
  15. child.detachNode();
  16. child.recycleNode();
  17. }
  18. }
  19. }

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

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

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

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

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

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

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

  1. public SOAPElement getFirstChildElement() {
  2. Iterator eachChild = getChildElements();
  3. javax.xml.soap.Node node = null;
  4. if (eachChild.hasNext()) {
  5. node = (javax.xml.soap.Node) eachChild.next();
  6. }else {
  7. return null;
  8. }
  9. while ((node.getNodeType() != Node.ELEMENT_NODE) && eachChild.hasNext()) {
  10. node = (javax.xml.soap.Node) eachChild.next();
  11. }
  12. if ((null != node) /*&& (node.getNodeType() == Node.ELEMENT_NODE)*/)
  13. return (SOAPElement) node;
  14. else
  15. return null;
  16. }

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

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

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

  1. /**
  2. * Takes a SOAPElement and checks if it has the right name and structure.
  3. */
  4. public EmbeddedReference(SOAPElement element) throws XWSSecurityException {
  5. setSOAPElement(element);
  6. if (!(element.getLocalName().equals("Embedded") &&
  7. XMLUtil.inWsseNS(element))) {
  8. log.log(Level.SEVERE,
  9. "WSS0752.invalid.embedded.reference");
  10. throw new XWSSecurityException("Invalid EmbeddedReference passed");
  11. }
  12. Iterator eachChild = getChildElements();
  13. Node node = null;
  14. while (!(node instanceof SOAPElement) && eachChild.hasNext()) {
  15. node = (Node) eachChild.next();
  16. }
  17. if ((node != null) && (node.getNodeType() == Node.ELEMENT_NODE)) {
  18. embeddedElement = (SOAPElement) node;
  19. } else {
  20. log.log(Level.SEVERE,
  21. "WSS0753.missing.embedded.token");
  22. throw new XWSSecurityException(
  23. "Passed EmbeddedReference does not contain an embedded element");
  24. }
  25. }

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

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

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

  1. @SuppressWarnings("unchecked")
  2. @Override
  3. public void removeHeaderElement(QName name) throws SoapHeaderException {
  4. Iterator<Node> iterator = getSaajHeader().getChildElements(name);
  5. if (iterator.hasNext()) {
  6. Node element = iterator.next();
  7. element.detachNode();
  8. }
  9. }

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

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

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

  1. @SuppressWarnings("unchecked")
  2. @Override
  3. public void removeHeaderElement(QName name) throws SoapHeaderException {
  4. Iterator<Node> iterator = getSaajHeader().getChildElements(name);
  5. if (iterator.hasNext()) {
  6. Node element = iterator.next();
  7. element.detachNode();
  8. }
  9. }

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

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

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

  1. @SuppressWarnings("unchecked")
  2. @Override
  3. public void removeHeaderElement(QName name) throws SoapHeaderException {
  4. Iterator<Node> iterator = getSaajHeader().getChildElements(name);
  5. if (iterator.hasNext()) {
  6. Node element = iterator.next();
  7. element.detachNode();
  8. }
  9. }

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

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

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

  1. firstBodyElement.detachNode();

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

  1. /**
  2. * Logs into the MS CRM 2011 Online
  3. *
  4. * @return the Live ID token
  5. * @throws JaxenException issue with the response format
  6. * @throws IOException generic IO issue
  7. * @throws SOAPException issue with SOAP invocation
  8. */
  9. public String login() throws IOException, SOAPException, JaxenException {
  10. String msg = FileUtil.readStringFromClasspath("/com/gooddata/msdynamics/LiveIdLogin.xml", MsDynamicsWrapper.class);
  11. msg = msg.replaceAll(LIVE_ID_SERVER_PLACEHOLDER, getHost());
  12. msg = msg.replaceAll(LIVE_ID_USERNAME_PLACEHOLDER, getUsername());
  13. msg = msg.replaceAll(LIVE_ID_PASSWORD_PLACEHOLDER, getPassword());
  14. msg = msg.replaceAll(LIVE_ID_POLICY_PLACEHOLDER, getPolicy());
  15. SOAPMessage response = soap.execute(HTTPS + LIVE_ID_HOST + LIVE_ID_ENDPOINT, msg);
  16. XPath xp = soap.createXPath("//wsse:BinarySecurityToken/text()", response);
  17. xp.addNamespace("wsse", WSSE_XMLNS);
  18. Node result = (Node) xp.selectSingleNode(response.getSOAPBody());
  19. return result.getValue();
  20. }

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

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

相关文章