background image

Creating an AttachmentPart Object

<< Running DOMExample and DOMSrcExample | Running Attachments >>
<< Running DOMExample and DOMSrcExample | Running Attachments >>
166
SOAP
WITH
A
TTACHMENTS
API
FOR
J
AVA
When you run DOMSrcExample using the file
domsrc2.xml
, you will see output
that begins like the following:
run-domsrc:
Running DOMSrcExample.
Body contents:
Content is:
Name is {urn:uddi-org:api_v2}businessList
Attribute name is generic
Attribute value is 2.0
Attribute name is operator
Attribute value is www.ibm.com/services/uddi
Attribute name is truncated
Attribute value is false
Attribute name is xmlns
Attribute value is urn:uddi-org:api_v2
...
If you run DOMSrcExample with the file
uddimsg.xml
or
slide.xml
, you will
see runtime errors.
Attachments.java
The example
Attachments.java
, based on the code fragments in the sections
Creating an AttachmentPart Object and Adding Content (page 137) and Access-
ing an AttachmentPart Object (page 139),
creates a message that has a text
attachment and an image attachment. It then retrieves the contents of the attach-
ments and prints the contents of the text attachment. You will find the code for
Attachments in the following directory:
<INSTALL>/javaeetutorial5/examples/saaj/attachments/src/
Attachments first creates a message in the usual way. It then creates an
Attach-
mentPart
for the text attachment:
AttachmentPart attachment1 = message.createAttachmentPart();