tags:

views:

18

answers:

2

Hello,

as part of my project, i need to be able to parse a SOAP response from a remote service end-point, and convert it into a custom XML format. my project should be agnostic of the schema used by the SOAP response. however, my first step involves parsing the SOAP message and extracting the relevant sections - Headers, Body, Attachments, Faults. Currently, to do this i'm using the StaX parser.

I was wondering if there's any toolkit available to perform this task so that i wouldn't have to re-invent the wheel again. especially more so when it comes to handling complexities related to retrieving binary data attachments w/ their correct Mime types, etc.

Some pseudo-code examples -

SOAPLib s = new SOAPLib(soapResp);
SOAPHeader h s.getHeader();
h.getHeaders();
String body = s.getBody()
SOAPAttachment sa = s.getAttachment(id);
...
...

any help is much appreciated.

A: 

SoapUI will work for you

org.life.java
i'm aware of that, however, their source is one big chunk. contains a sizeable portion related to their ui, groovy script execution support, rest services, load testing, etc. i just want a specialised library - of course, the last resort could be to dig into soapui's src and extract/recreate the corresponding modules.
anirvan
A: 

The "SOAP with Attachments API for Java (SAAJ)" is built into the jdk in the javax.xml.soap package. A tutorial can be found here.

The Api is based on the DOM, to parse a soap message you can either use the SoapFactory#createElement(Element domElement) method in SOAPFactory or the MessageFactory#createMessage(MimeHeaders headers, InputStream in) in MessageFactory.

Jörn Horstmann
I believe the SAAJ toolkit is provided to 'build' a SOAP message and not for parsing a SOAP message.
anirvan