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

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

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

SOAPHeader.getElementsByTagName介绍

暂无

代码示例

代码示例来源:origin: de.holisticon.util.tracee/tracee-jaxws

/**
 * Parses a context map from a given soap header.
 */
public Map<String, String> parse(SOAPHeader header) {
  final NodeList nodeList = header.getElementsByTagName(
      TraceeWsHandlerConstants.TRACEE_SOAP_HEADER_TAG_NAME);
  final Map<String, String> context = new HashMap<String, String>();
  for (int i = 0; i < nodeList.getLength(); i++) {
    final Node node = nodeList.item(i);
    final NodeList childNodeList = node.getChildNodes();
    for (int j = 0; j < childNodeList.getLength(); j++) {
      final Node childNode = childNodeList.item(j);
      final String attributeName = childNode.getNodeName();
      final String value = childNode.getTextContent();
      if (attributeName != null
          && !attributeName.isEmpty()
          && !"#text".equals(attributeName)) {
        context.put(attributeName, value);
      }
    }
  }
  return context;
}

代码示例来源:origin: gmazza/blog-samples

@Override
  public void handleMessage(SoapMessage message) throws Fault {
    SOAPMessage sm = message.getContent(SOAPMessage.class);

    try {
      SOAPHeader sh = sm.getSOAPHeader();
      /* Note in real use validity checking should be done
        (really two terms present? namespaces? etc.) */
      NodeList termNodes = sh.getElementsByTagName("term");
      message.put("termOne", termNodes.item(0).getTextContent());
      message.put("termTwo", termNodes.item(1).getTextContent());
      /* JAX-WS Handler "setScope()" (HANDLER/APPLICATION) 
        not available with interceptors, APPLICATION is standard
        meaning both properties readable by service bean */
    } catch (SOAPException e) {
      throw new Fault(e);
    } 
  }
}

代码示例来源:origin: gmazza/blog-samples

@Override
  public boolean handleMessage(SOAPMessageContext mc) {
   HandlerUtils.printMessageContext("Service SOAPHandler", mc);
   if (Boolean.FALSE.equals(mc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY))) {
     SOAPMessage sm = mc.getMessage();

     try {
      SOAPHeader sh = sm.getSOAPHeader();

      // Note in real use validity checking should be done
      // (really two terms present? namespaces? etc.)
      NodeList termNodes = sh.getElementsByTagName("term");
      mc.put("termOne", termNodes.item(0).getTextContent());
      mc.put("termTwo", termNodes.item(1).getTextContent());
      // default scope is HANDLER (i.e., not readable by SEI
      // implementation)
      mc.setScope("termTwo", MessageContext.Scope.APPLICATION);
     } catch (SOAPException e) {
      throw new ProtocolException(e);
     }
   }
   return true;
  }
}

相关文章