background image

SOAP messages and SOAP connections

<< SAAJ and DOM | Creating and Sending a Simple Message >>
<< SAAJ and DOM | Creating and Sending a Simple Message >>
T
UTORIAL
123
until it receives the response. Thus, the return value for the
call
method is the
SOAPMessage
object that is the response to the message that was sent. The
request
parameter is the message being sent;
endpoint
represents where it is
being sent.
SOAPConnectionFactory factory =
SOAPConnectionFactory.newInstance();
SOAPConnection connection = factory.createConnection();
. . .// create a request message and give it content
java.net.URL endpoint =
new URL("http://fabulous.com/gizmo/order");
SOAPMessage response = connection.call(request, endpoint);
Note that the second argument to the
call
method, which identifies where the
message is being sent, can be a
String
object or a
URL
object. Thus, the last two
lines of code from the preceding example could also have been the following:
String endpoint = "http://fabulous.com/gizmo/order";
SOAPMessage response = connection.call(request, endpoint);
A web service implemented for request-response messaging must return a
response to any message it receives. The response is a
SOAPMessage
object, just
as the request is a
SOAPMessage
object. When the request message is an update,
the response is an acknowledgment that the update was received. Such an
acknowledgment implies that the update was successful. Some messages may
not require any response at all. The service that gets such a message is still
required to send back a response because one is needed to unblock the
call
method. In this case, the response is not related to the content of the message; it
is simply a message to unblock the
call
method.
Now that you have some background on SOAP messages and SOAP connec-
tions, in the next section you will see how to use the SAAJ API.
Tutorial
This tutorial walks you through how to use the SAAJ API. First, it covers the
basics of creating and sending a simple SOAP message. Then you will learn
more details about adding content to messages, including how to create SOAP
faults and attributes. Finally, you will learn how to send a message and retrieve