List of utility methods to do SOAP Message
SOAPMessage | getSOAPMessage(Map Parses SOAP message from InputStream with headers. MimeHeaders mimeHeaders = new MimeHeaders(); for (Entry<String, String> entry : headerMap.entrySet()) { mimeHeaders.addHeader(entry.getKey(), entry.getValue()); SOAPMessage soapMessage = mf.createMessage(mimeHeaders, is); soapMessage.setProperty(SOAPMessage.WRITE_XML_DECLARATION, "true"); return soapMessage; |
SOAPMessage | getSOAPMessage(Source msg) get SOAP Message MessageFactory factory = MessageFactory.newInstance();
SOAPMessage message = factory.createMessage();
message.getSOAPPart().setContent(msg);
message.saveChanges();
return message;
|
String | getSOAPMessageAsString(SOAPMessage soapMessage) get SOAP Message As String try { TransformerFactory tff = TransformerFactory.newInstance(); Transformer tf = tff.newTransformer(); tf.setOutputProperty(OutputKeys.INDENT, "yes"); tf.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); Source sc = soapMessage.getSOAPPart().getContent(); ByteArrayOutputStream streamOut = new ByteArrayOutputStream(); StreamResult result = new StreamResult(streamOut); ... |
String | getSoapMessageString(SOAPMessage message) get Soap Message String try (ByteArrayOutputStream outStream = new ByteArrayOutputStream()) { Source source = message.getSOAPPart().getContent(); Transformer transformer = TransformerFactory.newInstance().newTransformer(); StreamResult streamResult = new StreamResult(outStream); transformer.transform(source, streamResult); String returnValue = outStream.toString("utf-8"); return returnValue; } catch (Exception e) { ... |
MessageFactory | getSOAPMsgFactory() get SOAP Msg Factory if (_msgFact == null) { _msgFact = MessageFactory.newInstance(); return _msgFact; |
String | getString(SOAPMessage msg) get String StringWriter w = new StringWriter(); StreamResult result = new StreamResult(w); print(msg, result); w.flush(); return w.toString(); |
boolean | hasAttachments(SOAPMessage message) Checks if the given SOAP message has attachments. if (message == null) { return false; if (message.countAttachments() == 0) { return false; return true; |
void | invokeOneWay(Dispatch invoke One Way String fRequest = String.format(request, args); dispatch.invokeOneWay(getSOAPMessage(makeStreamSource(fRequest))); |
boolean | isExceptionObject(Class o) is Exception Object final String behaviourString = "java.lang.Exception"; Class<?> behaviour; try { behaviour = Class.forName(behaviourString); } catch (ClassNotFoundException e) { throw new RuntimeException("Unable to determine interface behaviour from : " + behaviourString, e); return checkBehaviour(o, behaviour); ... |
boolean | isFaultMessage(final SOAPMessage msg) is Fault Message try { return msg.getSOAPBody().getFault() != null; } catch (final Exception ignore) { return false; |