background image

SAAJ Coffee Supplier Service

<< JAX-WS Coffee Supplier Service | SAAJ Client >>
<< JAX-WS Coffee Supplier Service | SAAJ Client >>

SAAJ Coffee Supplier Service

public ConfirmationBean placeOrder(OrderBean order) {
Date tomorrow = DateHelper.addDays(new Date(), 1);
ConfirmationBean confirmation =
new ConfirmationBean(order.getId(), DateHelper.dateToCalendar(tomorrow));
return confirmation;
}
The getPriceList method returns a PriceListBean object, which lists the name and price of
each type of coffee that can be ordered from this service. The getPriceList method creates the
PriceListBean
object by invoking a private method named loadPrices. In a production
application, the loadPrices method would fetch the prices from a database. However, our
loadPrices
method takes a shortcut by getting the prices from the
SupplierPrices.properties
file. Here are the getPriceList and loadPrices methods:
public PriceListBean getPriceList() {
PriceListBean priceList = loadPrices();
return priceList;
}
private PriceListBean loadPrices() {
String propsName =
"com.sun.cb.ws.server.SupplierPrices";
Date today = new Date();
Date endDate = DateHelper.addDays(today, 30);
PriceItemBean[] priceItems = PriceLoader.loadItems(propsName);
PriceListBean priceList =
new PriceListBean(DateHelper.dateToCalendar(today),
DateHelper.dateToCalendar(endDate), priceItems);
return priceList;
}
SAAJ Coffee Supplier Service
The SAAJ supplier service implements the arrangements that the supplier and the Coffee Break
have made regarding their exchange of XML documents. These arrangements include the kinds
of messages they will send, the form of those messages, and the kind of messaging they will do.
They have agreed to do request-response messaging using the SAAJ API (the javax.xml.soap
package).
SAAJ Coffee Supplier Service
The Java EE 5 Tutorial · September 2007
1032