background image

SAAJ Client

<< SAAJ Coffee Supplier Service | Sending the Request >>
<< SAAJ Coffee Supplier Service | Sending the Request >>

SAAJ Client

The Coffee Break servers send two kinds of messages:
Requests for current wholesale coffee prices
Customer orders for coffee
The SAAJ coffee supplier responds with two kinds of messages:
Current price lists
Order confirmations
All the messages they send conform to an agreed-upon XML structure, which is specified in a
DTD for each kind of message. This allows them to exchange messages even though they use
different document formats internally.
The four kinds of messages exchanged by the Coffee Break servers and the SAAJ supplier are
specified by the following DTDs:
request-prices.dtd
price-list.dtd
coffee-order.dtd
confirm.dtd
These DTDs can be found at
tut-install/javaeetutorial5/examples/coffeebreak/cb-saaj/dtds/. The dtds directory
also contains a sample of what the XML documents specified in the DTDs might look like.
The corresponding XML files for the DTDs are as follows:
request-prices.xml
price-list.xml
coffee-order.xml
confirm.xml
Because of the DTDs, both parties know ahead of time what to expect in a particular kind of
message and can therefore extract its content using the SAAJ API.
Code for the client and server applications is in this directory:
tut-install/javaeetutorial5/examples/coffeebreak/cb-saaj/src/java
SAAJ Client
The Coffee Break server, which is a SAAJ client in this scenario, sends requests to the SAAJ
supplier. The SAAJ client application uses the SOAPConnection method call to send messages.
SOAPMessage response = con.call(request, endpoint);
SAAJ Coffee Supplier Service
Chapter 36 · The Coffee Break Application
1033