java.lang.Objectorg.apache.xmlbeans.impl.soap.AttachmentPart
A single attachment to a SOAPMessage object. A
SOAPMessage object may contain zero, one, or many
AttachmentPart objects. Each
AttachmentPart object consists of two parts,
application-specific content and associated MIME headers. The
MIME headers consists of name/value pairs that can be used to
identify and describe the content.
An AttachmentPart object must conform to
certain standards.
Content-TypeAttachmentPart object and MUST
conform to [RFC2045]. The following is an example of a
Content-Type header:
Content-Type: application/xmlThe following line of code, in which
ap is
an AttachmentPart object, sets the header
shown in the previous example.
ap.setMimeHeader("Content-Type", "application/xml");
There are no restrictions on the content portion of an
AttachmentPart object. The content may be anything
from a simple plain text object to a complex XML document or
image file.
An AttachmentPart object is created with the
method SOAPMessage.createAttachmentPart. After
setting its MIME headers, the AttachmentPart
object is added to the message that created it with the method
SOAPMessage.addAttachmentPart.
The following code fragment, in which m is a
SOAPMessage object and contentStringl
is a String, creates an instance of
AttachmentPart, sets the AttachmentPart
object with some content and header information, and adds the
AttachmentPart object to the
SOAPMessage object.
AttachmentPart ap1 = m.createAttachmentPart(); ap1.setContent(contentString1, "text/plain"); m.addAttachmentPart(ap1);
The following code fragment creates and adds a second
AttachmentPart instance to the same message.
jpegData is a binary byte buffer representing the jpeg
file.
AttachmentPart ap2 = m.createAttachmentPart(); byte[] jpegData = ...; ap2.setContent(new ByteArrayInputStream(jpegData), "image/jpeg"); m.addAttachmentPart(ap2);
The getContent method retrieves the contents
and header from an AttachmentPart object.
Depending on the DataContentHandler objects
present, the returned Object can either be a typed
Java object corresponding to the MIME type or an
InputStream object that contains the content as
bytes.
String content1 = ap1.getContent(); java.io.InputStream content2 = ap2.getContent();The method
clearContent removes all the content
from an AttachmentPart object but does not affect
its header information.
ap1.clearContent();
| Constructor: |
|---|
|
| Method from org.apache.xmlbeans.impl.soap.AttachmentPart Summary: |
|---|
| addMimeHeader, clearContent, getAllMimeHeaders, getContent, getContentId, getContentLocation, getContentType, getMatchingMimeHeaders, getMimeHeader, getNonMatchingMimeHeaders, getSize, removeAllMimeHeaders, removeMimeHeader, setContent, setContentId, setContentLocation, setContentType, setMimeHeader |
| Methods from java.lang.Object: |
|---|
| equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method from org.apache.xmlbeans.impl.soap.AttachmentPart Detail: |
|---|
AttachmentPart object.
Note that RFC822 headers can contain only US-ASCII characters. |
AttachmentPart object. The MIME header portion is left
untouched. |
AttachmentPart object as an iterator over the
MimeHeader objects. |
AttachmentPart object as a Java
object. The type of the returned Java object depends on (1) the
DataContentHandler object that is used to interpret the bytes
and (2) the Content-Type given in the header.
For the MIME content types "text/plain", "text/html" and "text/xml", the
A JAXM-compliant implementation must, as a minimum, return a
|
|
|
|
MimeHeader objects that match
a name in the given array. |
String. |
MimeHeader objects whose name
does not match a name in the given array. |
AttachmentPart object. |
|
|
Object and sets the value of the
Content-Type header to the given type. The type of the
Object should correspond to the value given for
the Content-Type. This depends on the particular
set of DataContentHandler objects in use. |
|
|
|
Note that RFC822 headers can only contain US-ASCII characters. |