background image

JAX-WS Coffee Supplier Service

<< Coffee Break Application Flow | SAAJ Coffee Supplier Service >>
<< Coffee Break Application Flow | SAAJ Coffee Supplier Service >>

JAX-WS Coffee Supplier Service

5. When an order is placed, suborders are sent to one or more suppliers using the supplier's
preferred protocol.
Common Code
The Coffee Break servers share the CoffeeBreak.properties file, which contains the URLs
exposed by the JAX-WS and SAAJ suppliers; the URLHelper class, which is used by the server
and client classes to retrieve the URLs; the DateHelper utility class; and several generated
JavaBeans components, described in
"JAX-WS Coffee Supplier Service" on page 1031
. These
JavaBeans components are generated from the cb-jaxws JAX-WS web service by the wsimport
tool.
The source code for the shared files is in the
tut-install/javaeetutorial5/examples/coffeebreak/
cb-common/src/java/com/sun/cb/common/
directory.
JAX-WS Coffee Supplier Service
The Coffee Break servers are clients of the JAX-WS coffee supplier service. The service code
consists of the service implementation class, and several JavaBeans components that are used
for method parameters and return types. The JavaBeans components are:
AddressBean
: shipping information for customer
ConfirmationBean
: order ID and ship date
CustomerBean
: customer contact information
LineItemBean
: order item
OrderBean
: order ID, customer, address, list of line items, total price
PriceItemBean
: price list entry (coffee name and wholesale price)
PriceListBean
: price list
These JavaBeans components are propagated to the clients by means of the wsimport tool.
Service Implementation
The Supplier class implements the placeOrder and getPriceList methods. So that you can
focus on the code related to JAX-WS, these methods are short and simplistic. In a real world
application, these methods would access databases and would interact with other services, such
as shipping, accounting, and inventory.
The placeOrder method accepts as input a coffee order and returns a confirmation for the
order. To keep things simple, the placeOrder method confirms every order and sets the ship
date in the confirmation to the next day. The source code for the placeOrder method follows:
JAX-WS Coffee Supplier Service
Chapter 36 · The Coffee Break Application
1031