SAAJ/JAXM vs. Apache SOAP: What are the differences between these two and which is better for using SOAP with attachments? JAXM is a Service Provicer Interface (SPI) specification. JAXM handles XML using a DOM-oriented model and allows you to examine the contents of a SOAP message by retrieving individual attachment parts. JAXM encapsulates attachments in an object called an AttachmentPart. You set the MIME headers for each AttachmentPart...
object, then add it to a message.
The getContent method retrieves the contents and header from an AttachmentPart object. Using DataContentHandler objects, you can handle the attachment as a Java object corresponding to the MIME type or as an InputStream containing the content as bytes.
Apache SOAP also handles XML using a DOM-oriented model. Methods for handling attachments in message-encoding style SOAP are provided in the classes; org.apache.soap.messaging.Message, org.apache.soap.rpc.Call, or org.apache.soap.rpc.Response. Use addBodyPart() to add a an attachment as a javax.mail.internet.MimeBodyPart object. Use findBodyPart() to retrieve attachments using a Content-URI and getBodyPart() to retrieve attachments using a location within a message.
Another alternative to JAXM and Apache SOAP is Axis, the next generation of Apache SOAP. Axis handles XML using SAX which can result in a performance boost for you, depending upon how you are using it.
If you are comfortable with a DOM-oriented model, JAXM or Apache SOAP are both viable options, however, Apache SOAP is slightly more mature. If you need to interface as a new service provider, JAXM is a more elegant option. If you need the performance that SAX can offer, Axis is probably your best choice.
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.