Ordering Coffee

The other kind of message that the Coffee Break servers can send to
the SAAJ supplier is an order for coffee. This is done in the placeOrder method of OrderRequest, which follows the DTD coffee-order.dtd.

Creating the Order

As with the client code for requesting a price list, the placeOrder method starts by creating a SOAPConnection object
and a SOAPMessage object and accessing the message’s SOAPBody object.

Because the given endpoint is mapped to ConfirmationServlet,
the Application Server executes that servlet (discussed in Returning the Order Confirmation) to create and
return the SOAPMessage object reply.

Retrieving the Order Confirmation

The rest of the placeOrder method retrieves the information
returned in reply. The client knows what elements are in
it because they are specified in confirm.dtd. After accessing
the SOAPBody object, the code retrieves the confirmation element and gets the text of the orderID and ship-date elements. Finally, it constructs and returns a ConfirmationBean with this information.