background image

Creating and Sending a Simple Message

<< SOAP messages and SOAP connections | Parts of a Message >>
<< SOAP messages and SOAP connections | Parts of a Message >>
124
SOAP
WITH
A
TTACHMENTS
API
FOR
J
AVA
the content of the response. After going through this tutorial, you will know how
to perform the following tasks:
· Creating and sending a simple message
· Adding content to the header
· Adding content to the
SOAPPart
object
· Adding a document to the SOAP body
· Manipulating message content using SAAJ or DOM APIs
· Adding attachments
· Adding attributes
· Using SOAP faults
In the section Code Examples (page 151), you will see the code fragments from
earlier parts of the tutorial in runnable applications, which you can test yourself.
A SAAJ client can send request-response messages to web services that are
implemented to do request-response messaging. This section demonstrates how
you can do this.
Creating and Sending a Simple
Message
This section covers the basics of creating and sending a simple message and
retrieving the content of the response. It includes the following topics:
· Creating a message
· Parts of a message
· Accessing elements of a message
· Adding content to the body
· Getting a
SOAPConnection
object
· Sending a message
· Getting the content of a message
Creating a Message
The first step is to create a message using a
MessageFactory
object. The SAAJ
API provides a default implementation of the
MessageFactory
class, thus mak-