NonStop SOAP for Java User's Manual

Using the SOAP Client APIs
NonStop SOAP for Java User’s Manual523860-001
6-3
Using Attachments
Using Attachments
This section describes SOAP messages with attachments. The SOAP messages with
attachments proposal has been published as a W3C Note at
http://www.w3.org.TR/SOAP-attachments. In this scheme, the MIME
(Multipurpose Internet Mail Extensions) multipart message format is used to bundle a
complete standard SOAP message with additional data in a “SOAP message
package.” The SOAP message, occupying the first position in the package, can
incorporate references to the other parts of the message using a naming convention
described in the note. SOAP message packages can be transmitted by HTTP, SMTP
(Simple Mail Transport Protocol), or any other message protocol.
Background
Even though SOAP is an XML-based protocol, it is not always convenient to force all
data, which is passed as part of a SOAP message to be encoded in a way, which can
be embedded inside of an XML document. Sometimes it would be cleaner to allow
data, such as JPEG images, WAV files, and so on, to be passed along with the SOAP
message, instead of inside of it. To address this issue, the SOAP Messages with
Attachments specification was created. The SOAP Messages with Attachments
specification allows for the embedding of a SOAP message inside of a MIME
document, in a manner in which does not alter the processing rules of the message.
The SOAP Messages with Attachments specification also describes how you refer to
the attachments from inside the body of the SOAP message. Apache SOAP contains
an implementation of this specification.
Using Attachments on the Client
If you are interacting with an RPC-based service, you may not need to do anything
special to transmit an attachment. Pre-defined serializers/deserializers exist for
interacting with javax.activation.DataSource objects and
javax.activation.DataHandler objects. If your objects can be passed through
one of these mechanisms then the RPC-code will handle creating and or removing the
attachment for you.
If you are using a message-oriented service, you can use methods in one of the
following classes:
org.apache.soap.messaging.Message
org.apache.soap.rpc.Call
org.apache.soap.rpc.Response classes
The addBodyPart(...) methods allow you to add a
javax.mail.internet.MimeBodyPart object to your messages, while the
findBodyPart(...) and getBodyPart(...) methods allow you to retrieve
them through the Content-URI and location within the message, respectively.