List of utility methods to do SOAP Message
List | getNamespaceURIs(SOAPMessage soap) Returns namespace URIs from a SOAPMessage. List<String> nsURIs = new ArrayList<>(); SOAPEnvelope envelope = soap.getSOAPPart().getEnvelope(); Iterator<?> it = envelope.getNamespacePrefixes(); while (it.hasNext()) { nsURIs.add(envelope.getNamespaceURI((String) it.next())); return nsURIs; |
Node | getNode(Node node, String nodeName) Goes through all the child nodes of the given node and returns the first child that matches the given name. for (int i = 0; i < node.getChildNodes().getLength(); i++) { if (node.getChildNodes().item(i).getNodeType() == Node.ELEMENT_NODE && node.getChildNodes().item(i).getLocalName().equals(nodeName)) { return (Node) node.getChildNodes().item(i); return null; |
String | getPrefix(Name name) get Prefix String prefix = name.getPrefix();
return prefix == null || prefix.length() == 0 ? null : prefix;
|
String | getPrefix(String namespaceURI, SOAPElement contextElem) get Prefix Iterator prefixIt = contextElem.getVisibleNamespacePrefixes(); while (prefixIt.hasNext()) { String prefix = (String) prefixIt.next(); if (namespaceURI.equals(contextElem.getNamespaceURI(prefix))) return prefix; return null; |
Document | getSOAPData(SOAPMessage soapMessage) Given a SOAPMessage , get the content as a Document return soapMessage.getSOAPBody().extractContentAsDocument();
|
String | getSoapFaultExceptionMessage(SOAPFaultException sfe) get Soap Fault Exception Message if (sfe.getFault().hasDetail()) { return sfe.getFault().getDetail().getFirstChild().getLocalName(); if (sfe.getFault().getFaultString() != null) { return "\n Message: " + sfe.getFault().getFaultString(); return sfe.getMessage(); |
SOAPHeader | getSOAPHeader(SOAPMessageContext smc) Returns the header. return smc.getMessage().getSOAPPart().getEnvelope().getHeader() == null
? smc.getMessage().getSOAPPart().getEnvelope().addHeader()
: smc.getMessage().getSOAPPart().getEnvelope().getHeader();
|
SOAPHeaderElement | getSOAPHeaderElement(SOAPMessage message, String headerName, String nameSpace) get SOAP Header Element Iterator it = message.getSOAPHeader().examineAllHeaderElements(); while (it.hasNext()) { SOAPHeaderElement she = (SOAPHeaderElement) it.next(); String uri = she.getNamespaceURI(); String localName = she.getLocalName(); if (headerName.equals(localName) && nameSpace.equals(uri)) { return she; return null; |
Document | getSOAPMessage(InputStream in) A method to get the SOAP message from the input stream. DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); DocumentBuilder db = dbf.newDocumentBuilder(); Document soapMessage = db.newDocument(); Transformer t = TransformerFactory.newInstance().newTransformer(); t.transform(new StreamSource(in), new DOMResult(soapMessage)); return soapMessage; |
SOAPMessage | getSOAPMessage(InputStream is) Given a stream of SOAPMessage , construct the SOAPMessage MessageFactory messageFactory = MessageFactory.newInstance();
return messageFactory.createMessage(null, is);
|