List of utility methods to do SOAP Message
byte[] | toByteArray(SOAPMessage soapMessage) to Byte Array ByteArrayOutputStream bos = new ByteArrayOutputStream(); soapMessage.writeTo(bos); return bos.toByteArray(); |
String | toPrettyString(SOAPMessage response) to Pretty String TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); Source content = response.getSOAPPart().getContent(); StringWriter writer = new StringWriter(); StreamResult result = new StreamResult(writer); transformer.transform(content, result); ... |
SOAPMessage | toSOAPMessage(String msgString) Method used to convert Strings to SOAPMessages if (msgString == null) return null; SOAPMessage message = null; try { MessageFactory factory = null; if (msgString.indexOf(SOAP11_NAMESPACE) >= 0) { factory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL); } else { ... |
org.w3c.dom.Document | toSOAPPart(String xml) Convert an xml String to a Document ByteArrayInputStream in = new ByteArrayInputStream(xml.getBytes()); MessageFactory factory = MessageFactory.newInstance(); SOAPMessage soapMessage = factory.createMessage(null, in); return soapMessage.getSOAPPart(); |
org.w3c.dom.Document | toSOAPPart(String xml) Convert an SOAP Envelope as a String to a org.w3c.dom.Document. DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); InputStream in = new ByteArrayInputStream(xml.getBytes()); DocumentBuilder builder = factory.newDocumentBuilder(); return builder.parse(in); |
String | toString(SOAPMessage soapMessage) to String return new String(toByteArray(soapMessage)); |
SOAPMessage | writeAndRead(SOAPMessage soapMessage) write And Read ByteArrayOutputStream soapSink = new ByteArrayOutputStream(); soapMessage.writeTo(soapSink); soapSink.writeTo(System.out); System.out.println(); return MessageFactory.newInstance().createMessage(null, new ByteArrayInputStream(soapSink.toByteArray())); |