List of usage examples for javax.xml.soap SOAPHeaderElement getTextContent
public String getTextContent() throws DOMException;
From source file:cn.com.ttblog.ssmbootstrap_table.webservice.LicenseHandler.java
@SuppressWarnings("unchecked") @Override/*from w w w . j av a 2 s . c o m*/ public boolean handleMessage(SOAPMessageContext context) { try { Boolean out = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); logger.debug("LicenseHandler:{}", out); if (!out) { SOAPMessage message = context.getMessage(); logger.debug("SOAPMessage:{}", ToStringBuilder.reflectionToString(message)); SOAPEnvelope enve = message.getSOAPPart().getEnvelope(); SOAPHeader header = enve.getHeader(); SOAPBody body = enve.getBody(); Node bn = body.getChildNodes().item(0); String partname = bn.getLocalName(); if ("getUser".equals(partname)) { if (header == null) { // ? SOAPFault fault = body.addFault(); fault.setFaultString("??!"); throw new SOAPFaultException(fault); } Iterator<SOAPHeaderElement> iterator = header.extractAllHeaderElements(); if (!iterator.hasNext()) { // ? SOAPFault fault = body.addFault(); fault.setFaultString("??!"); throw new SOAPFaultException(fault); } while (iterator.hasNext()) { SOAPHeaderElement ele = iterator.next(); System.out.println(ele.getTextContent()); } } } } catch (SOAPException e) { e.printStackTrace(); } return true; }
From source file:com.centurylink.mdw.hub.servlet.SoapServlet.java
protected Map<String, String> addSoapMetaInfo(Map<String, String> metaInfo, SOAPMessage soapMessage) throws SOAPException { SOAPHeader soapHeader = soapMessage.getSOAPHeader(); if (soapHeader == null) { return metaInfo; } else {/*from ww w .j av a 2s. c o m*/ Map<String, String> newMetaInfo = new HashMap<String, String>(); newMetaInfo.putAll(metaInfo); Iterator<?> iter = soapHeader.examineAllHeaderElements(); while (iter.hasNext()) { SOAPHeaderElement headerElem = (SOAPHeaderElement) iter.next(); if (!Listener.AUTHENTICATED_USER_HEADER.equals(headerElem.getNodeName())) newMetaInfo.put(headerElem.getNodeName(), headerElem.getTextContent()); } return newMetaInfo; } }