Logisticx Server Side
The Logisticx Server Side
Logisticx back end applications do not communicate directly. The server side applications utilize the JBI model of mediation via the Normalized Message Router (NMR).
Applications
Order Service Assembly
The Order web service is deployed as a single Service Assembly (SA) using the FUSE Services Framework (based on Apache CXF) Binding Component (BC) and Service Engine (SE) within Fuse ESB. The CXF BC creates an HTTP listener that routes incoming messages to the CXF SE. The Order Service is implemented as a Java first JSR-181 web service and utilizes the java2wsdl generator from CXF to generate WSDL which is made available through the CXF BC for clients.
The OrderServiceImpl receives the incoming order message and uses a utility class (OrderServiceSupport) to persist the Order to a Derby database using OpenJPA. This step demonstrates using annotations on the same domain model objects (Order, LineItems, OrderStatus) for marshalling from the web service calls and JPA persistence. The JPA persistence generates a unique ID for the order and populates this ID in the Order object that was passed from the web service.
The Order object is then used to create an OrderStatus object that is used to notify other interested parties of the order. The OrderServiceImpl then uses OrderServiceSupport to send the OrderStatus message to the orderProcessor endpoint using the ServiceMix API. See Order Processor below.
Order Service HTTP SU (CXF BC)
The order service is exposed through deployment of an HTTP listener via the CXF BC. The CXF BC is a specialized HTTP listener that works in conjunction with the CXF SE. This SU is an example of a simple listener that exposes the WSDL for the target endpoint and send incoming requests through the NMR to the target CXF SE endpoint.
Order Web Service Service SU (CXF SE)
The Order Web Service is deployed using the CXF SE to expose the service as a generic CXF service endpoint. In this case the service was started as simple Java POJO code, and was enhanced with JSR-181 annotations to specify the parameters used to expose the service and generate WSDL that describes it. Apache CXF provides a code generation utility to generate the WSDL and any required wrappers and can be called from the command line, Ant, or via a Maven plugin. The alternative is to create hand crafted WSDL that can use the same code generation to create Java interfaces to implement for providing the service and CXF has tools to do it either way. Below is the OrderServiceImpl class. Notice the JSR-181 annotations:
@WebService(name = "OrderService", targetNamespace = "http://logisticx.com/orderService/") public class OrderServiceImpl implements OrderService { OrderServiceSupport support = new OrderServiceSupport(); /** * The JBI component context to provide access to items such as the {@link DeliveryChannel}, {@link ServiceEndpoint}s, * the endpoint registry and other important JBI */ private ComponentContext context; /** * Used to submit a single {@link com.logisticx.model.Order} */ @WebMethod public OrderStatus putOrder(Order order) { support.persist(order); OrderStatus status = new OrderStatus(OrderStatus.StatusCode.ORDER_PLACED); status.setOrder(order); status.setComments("Thank you for your order! Your order# is " + order.getOrderId()); support.send(status); return status; } /** * Used to check the status of an order. */ @WebMethod public OrderStatus getOrderStatus(long orderId) { return null; } /** * Used by the <a href="">servicemix-cxf-se</a> JBI component to inject the * JBI component context. * * @param context */ public void setContext(ComponentContext context) { this.context = context; this.support.setContext(context); } }
After sending to the Order Processor, OrderServiceImpl returns the OrderStatus as the reply to the original order message from the web client. The OrderStatus provides feedback about the order and allows the backend to augment the data in the order and provide an order ID that can be used to later retrieve information and updated status about the order.
