Creating an AttachmentPart Object
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
, based on the code fragments in the sections
<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();