6 Packing and Shipping Orders

This chapter describes how Oracle SOA Suite addresses the business challenge of packing and shipping orders. Overviews of how key SOA composite application components address this challenge are provided, including a REST service, BPEL process, HTTP Analyzer, BPEL process component template, standalone BPEL subprocess, composite sensor, and Oracle User Messaging Service adapter.

This chapter includes the following sections:

6.1 Business Challenge

Company X has a requirement for assigning preferred shipping providers to a specific shipping method. This method is calculated based on the shipping speed the customer selected when placing the order and the shipping state (in the address). Once the order has been shipped, a notification must be sent to the customer confirming the shipping provider. The order status must also be updated to shipped.

6.2 Business Solution

To address this business challenge, Company X designs a business solution that uses the components described in Table 6-1.

Table 6-1 Components That Provide the Business Solution

Component How This Component Addresses the Business Challenge Component Description

REST service

An inbound REST adapter service defines a shipping resource.

REST is an architecture for designing network applications. RESTful applications use HTTP requests to post data (create and update), get data (for example, make queries), update data, and delete data.

BPEL process

A BPEL process sets the status of the order to shipped, notifies the customer that the order has shipped, and updates the order status in the database. This process is connected to the REST interface, which is exposed as a service.

BPEL processes provide process orchestration and storage of a synchronous or an asynchronous process. You design a business process that integrates a series of business activities and services into an end-to-end process flow.

HTTP Analyzer

The HTTP Analyzer tests the Web Application Description Language (WADL) URL of the REST service to ensure that the service is working properly.

The HTTP Analyzer enables you to examine the content of HTTP request/response package pairs. You can edit the content of a request package, resend it, and observe the response packet returned.

BPEL process component template

The component template includes an invoke activity and an assign activity that takes an order number and an order status and assigns it to the input variable of the database adapter.

See Table 3-1 for a description of Oracle SOA Suite templates.

Standalone BPEL subprocess

A standalone BPEL process calls a database adapter reference to update the order status.

A standalone BPEL subprocess is a fragment of a BPEL process, which includes a number of activities to reuse. Standalone subprocess do not have an interface and are only called from another BPEL process.

Composite sensor

A composite sensor tracks all orders of a specific shipping provider.

See Table 3-1 for a description of composite sensors.

Oracle Enterprise Manager Fusion Middleware Control

Oracle Enterprise Manager Fusion Middleware Control monitors the composite sensor in the instance and provides access to a WADL URL used for testing.

Oracle Enterprise Manager Fusion Middleware Control is a web browser-based, graphical user interface that you use to monitor and administer your deployed composites.

Oracle User Messaging Service (UMS) adapter

A UMS adapter sends an email notification to a customer indicating the order was shipped.

UMS is an Oracle Fusion Middleware component that enables communication between users and applications. UMS supports various messaging channels such as email, SMS, and instant messaging (IM). UMS consists of servers, drivers, and applications.

Figure 6-1 provides an overview of how this business solution is implemented.

Figure 6-1 Packing and Shipping Process Overview

Description of Figure 6-1 follows
Description of "Figure 6-1 Packing and Shipping Process Overview"

Subsequent sections of this chapter provide more specific details about how the components in Table 6-1 are used to address the packing and shipping business challenge.

6.2.1 Defining a Shipping Resource with a REST Service

Company X creates a SOA composite application named PackAndShipService to address this business challenge. As an alternative to using a web service, Company X uses a REST service in the composite to define a shipping resource.

REST is an architecture for designing network applications. RESTful applications use HTTP requests to post data (create and update), get data (for example, make queries), update data, and delete data.

Oracle SOA Suite provides the following REST support:

  • Support in SOA composite applications:

    • Enable REST support in new or existing services.

    • Integrate with external REST APIs.

    • Orchestrate a set of RESTful state transitions (RPC/Hypermedia as the Engine of Application State (HATEOAS) approach).

    • Support for XML, JavaScript Object Notation (JSON) (with automatic translation to and from XML), URI sample, and URL-encoded GET/POST data.

    • Generation of sample URI for REST service operations.

    • Support for WADL services. The WADL can be provided by a deployed Oracle SOA Suite or Oracle Service Bus service or a non-Oracle SOA Suite or Oracle Service Bus service such as a Jersey REST service.

  • Ease of development:

    • Oracle JDeveloper provides a wizard for modeling REST interfaces and WSDL operation bindings.

    • Readable API is provided that publishes each method used upon deployment.

    • Ability to browse and consume Oracle REST endpoints (including Oracle Service Bus) from within Oracle JDeveloper.

  • Oracle Web Service Manager (OWSM) policy support for REST security.

Company X drags a REST binding adapter from the Components window into the Exposed Services swimlane in Oracle JDeveloper. The packing service expects a shipping resource that includes all necessary information to pack and ship an order. It returns a shipping resource with an updated order status.

Company X defines the following REST service details:

When design is complete, the Create REST Binding dialog looks as shown in Figure 6-4.

Figure 6-4 Create REST Binding Dialog - Design Complete

Description of Figure 6-4 follows
Description of "Figure 6-4 Create REST Binding Dialog - Design Complete"

This creates a REST service binding component in the Exposed Services swimlane, as shown in Figure 6-5.

Figure 6-5 REST Service in Exposed Services Swimlane in Oracle JDeveloper

Description of Figure 6-5 follows
Description of "Figure 6-5 REST Service in Exposed Services Swimlane in Oracle JDeveloper"

6.2.2 Exposing a REST Service with a Packing BPEL Process

Company X exposes the REST service by connecting it to a BPEL process, as shown in Figure 6-6.

Figure 6-6 REST Service Connected to BPEL Process

Description of Figure 6-6 follows
Description of "Figure 6-6 REST Service Connected to BPEL Process"

This service initiates the packing and shipping based on shipping provider and shipping method, which are both determined by the order fulfillment service in Fulfilling Orders . The BPEL process consists of the following activities:

  • A receive activity receives a call from the REST service.

  • An empty activity simulates the packing and shipping. After this activity is processed, the order status is updated to Shipped.

  • An assign activity assigns the order number and status to two variables:

    • orderNumber is set from the input variable

    • orderStatus is set to Shipped

  • An assign activity assigns the value of the input variable (with updated status) to the output variable.

  • A reply activity returns information to the REST service.

The complete design of the BPEL process is shown in Figure 6-7.

Figure 6-7 REST Service Integration with the BPEL Process

Description of Figure 6-7 follows
Description of "Figure 6-7 REST Service Integration with the BPEL Process"

6.2.3 Testing REST Services with the HTTP Analyzer

To ensure that the REST service is working properly, Company X first deploys the SOA composite application for testing with the HTTP Analyzer.

Deployment is performed by right-clicking the PackAndShipService in the Applications window, selecting Deploy, and going through the pages of the Deploy wizard. Deployment is performed to the IntegratedWebLogicServer, an embedded, local server in Oracle JDeveloper.

The HTTP Analyzer enables you to examine the content of HTTP request/response package pairs. You can edit the content of a request package, resend it, and observe the response packet returned.

To test the service, Company X first copies the WADL file URL from the home page of the PackAndShipService SOA composite application in Oracle Enterprise Manager Fusion Middleware Control, as shown in Figure 6-8.

REST services in Oracle SOA Suite expose WADL files instead of WSDL files to define their interface. WADL provides a readable XML description of HTTP-based web applications (typically REST web services). WADL simplifies the reuse of web services based on the existing HTTP architecture of the web.

Figure 6-8 WADL URL Location in Oracle Enterprise Manager Fusion Middleware Control

Description of Figure 6-8 follows
Description of "Figure 6-8 WADL URL Location in Oracle Enterprise Manager Fusion Middleware Control"

Company X then opens the HTTP Analyzer in Oracle JDeveloper by selecting Tools > HTTP Analyzer. Company X clicks Open URL and enters the WADL URL copied from Oracle Enterprise Manager Fusion Middleware Control, when prompted. Figure 6-9 provides details.

The Service dialog shown in Figure 6-10 displays details about the REST service. Company X clicks Test.

Company X copies and pastes the sample request XML payload specified in Figure 6-2 into the Request HTTP Headers section and clicks Send Request, as shown in Figure 6-11.

Figure 6-11 Request XML Payload Input to HTTP Analyzer

Description of Figure 6-11 follows
Description of "Figure 6-11 Request XML Payload Input to HTTP Analyzer"

6.2.4 Using Templates and Standalone Subprocesses to Update the Order Status in the Database

In addition to updating the order status in the shipping message, Company X also updates it in the database. Because this is a common task, Company X creates a component template named updateOrderStatusSP for reuse as needed in multiple projects. Company X used templates for similar common tasks in Calculating Payment Status with XSLT Transformations and Customizing the Contents of the SOA Project Template.

Figure 6-12 shows the component template contents.

Figure 6-12 BPEL Process Component Template Contents

Description of Figure 6-12 follows
Description of "Figure 6-12 BPEL Process Component Template Contents"

Company X drags the template from the Component Templates section of the Components window into the SOA composite application. When fully expanded, the composite looks as shown in Figure 6-13.

Figure 6-13 SOA Composite Application with Expanded Template

Description of Figure 6-13 follows
Description of "Figure 6-13 SOA Composite Application with Expanded Template"

The component template includes an invoke activity and an assign activity that takes an order number and an order status and assigns it to the input variable of the database adapter.

The packAndShipOrder BPEL process must be connected with the updateOrderStatusSP component template. To address this task, Company X uses a standalone BPEL subprocess to call a database adapter reference to update the order status. Subprocesses are similar to templates in that they enable you to reuse functionality in multiple projects. A standalone BPEL subprocess is a fragment of a BPEL process, which includes a number of activities to reuse. Standalone subprocesses do not have an interface and are only called from another BPEL process. A standalone process can have partner links across a number of other BPEL processes.

Company X opens the packAndShipOrder BPEL process and drags a standalone BPEL process from the Standalone section of the Components window into the process.

The standalone BPEL process is displayed as a call activity, which calls the updateOrderStatusSP template. It provides the following:

  • Order number

  • Order status

Figure 6-14 shows the contents of the call activity. A call activity enables you to execute referenced subprocess code in standalone and inline subprocesses.

Figure 6-14 Contents of Call Activity

Description of Figure 6-14 follows
Description of "Figure 6-14 Contents of Call Activity"

6.2.5 Tracking the Shipping Provider with Composite Sensors

Company X added a composite sensor for tracking the status of order payments in Tracking Payment Status with Composite Sensors and tracking the order number in Tracking the Order Number with Composite Sensors.

Company X now has an additional requirement for a composite sensor to track the shipping provider. This enables Company X to search for all orders that have been shipped with a specific shipping provider.

Company X defines the composite sensor on the REST service. The definition includes an XPath expression to track the shipping provider, as shown in the Composite Sensor dialog in Figure 6-15.

Figure 6-15 Composite Sensor for Tracking the Shipping Order

Description of Figure 6-15 follows
Description of "Figure 6-15 Composite Sensor for Tracking the Shipping Order"

The Enterprise Manager check box of the Composite Sensor dialog is also selected. This enables you to track composite sensor names and values on the Flow Instances page or the Flow Trace page for a specific business flow instance in Oracle Enterprise Manager Fusion Middleware Control. Figure 6-16 provides details.

Figure 6-16 Composite Sensor Name and Value in Flow Trace Page

Description of Figure 6-16 follows
Description of "Figure 6-16 Composite Sensor Name and Value in Flow Trace Page"

6.2.6 Sending Email Notifications to Indicate Order Shipments

Company X must be able to notify customers by email that an order has shipped. To address this task, Company X configures a UMS adapter to send an email notification to customers.

UMS is an Oracle Fusion Middleware component that enables communication between users and applications. UMS supports various messaging channels such as email, SMS, and instant messaging (IM). UMS consists of the following components:

  • A UMS server that orchestrates message flows between applications and users.

  • UMS drivers that connect UMS to the messaging gateways, adapting content to the various protocols supported by UMS.

  • UMS client applications that implement the business logic of sending and receiving messages.

The UMS adapter is dragged from the Technology section of the Components window to the External References swimlane. Company X configures the UMS adapter to perform the following tasks:

  • Send an outbound notification

  • Uses email as the notification channel

  • Add an email subject of Your Order Has Been Shipped

  • Configure the From and To email addresses

Figure 6-17 provides details.

Figure 6-17 UMS Adapter Configuration Wizard

Description of Figure 6-17 follows
Description of "Figure 6-17 UMS Adapter Configuration Wizard"

When UMS configuration is complete, the packAndShipOrder BPEL process is connected to the NotifyUser UMS adapter reference. Figure 6-18 provides details.

Figure 6-18 BPEL Process Connected to the UMS Adapter

Description of Figure 6-18 follows
Description of "Figure 6-18 BPEL Process Connected to the UMS Adapter"

To complete configuration, Company X adds the appropriate activities to the packAndShipOrder BPEL process:

  • An invoke activity to invoke the UMS adapter (with an input variable)

  • An assign activity to populate the payload of the input variable of the invoke activity

Figure 6-19 provides an overview of how this completed business solution appears in the SOA Composite Editor.

Figure 6-19 Completed SOA Composite Application

Description of Figure 6-19 follows
Description of "Figure 6-19 Completed SOA Composite Application"

6.3 Related Documentation

Table 6-2 provides references to documentation that more specifically describes the components and features described in this chapter.

Table 6-2 Related Documentation

For Information About... See...

Integrating a REST operation

Integrating REST Operations in SOA Composite Applications in Developing SOA Applications with Oracle SOA Suite

Creating and designing a BPEL process

Getting Started with Oracle BPEL Process Manager in Developing SOA Applications with Oracle SOA Suite

Using the HTTP Analyzer

Monitoring HTTP Using the HTTP Analyzer in Developing Applications with Oracle JDeveloper

Creating Oracle SOA Suite templates and standalone BPEL subprocesses

Oracle SOA Suite Templates and Reusable Subprocesses in Developing SOA Applications with Oracle SOA Suite

Creating composite sensors

Defining Composite Sensors in Developing SOA Applications with Oracle SOA Suite

Configuring the UMS Adapter

Oracle JCA Adapter for UMS in Understanding Technology Adapters

Developing Applications with Oracle User Messaging Service

Using the Integrated WebLogic Server

Introducing the Quick Start Distributions in Installing SOA Suite and Business Process Management Suite Quick Start for Developers