Welcome!

SOA & WOA Authors: Kevin Jackson, Maureen O'Gara, John Savageau, Greg Ness, Bruce Johnston

Related Topics: SOA & WOA

SOA & WOA: Article

Building a Business Logic Layer Over Multiple Web Services

Building a Business Logic Layer Over Multiple Web Services

Over the last few years, there have been significant developments in the Web services world. Many enterprises have embraced Web services to build business-to-business transactions and a uniform communication layer among applications over corporate intranets. This article discusses how to leverage application resident business logic by building a business logic layer over multiple Web services.

Many businesses are adopting Web services to gain access to applications and legacy databases that reside inside corporate networks (usually behind corporate firewalls). Web services have changed the B2B model from centrally located, exchange-oriented B2B APIs to distributed, corporate network-resident APIs. This model has gained huge popularity because it gives corporations complete control over the applications they run and also allows them to expose only those areas that are of interest to their business partners and those they deem appropriate to expose to the world. In the future it will be hard to imagine any businesses running all the applications internally without communicating with any other businesses or partners. Since Web services allow businesses to gain access to partial business logic and data residing within other businesses, the technology also opens up a whole new area for building a business logic layer that can operate over several other Web services in real time. The central idea of this article is how to build a logical layer serving as a Web service over other multiple Web services accessing remote applications and analyzing responses obtained from those Web services in real time. We use a simple case study based on JAX-RPC to build two Web services, "Timesheet" and "Insurance," and also build a logical layer, "Payroll," to evaluate responses from these two Web services. The "Payroll" client can easily be represented as another Web service that satisfies requests from such parties as your payroll processing company. We will also discuss EAI/BPM service integration techniques.

Web services, broadly speaking, are services offered via the Web. It is a platform-, vendor-, and language-independent, request-response model. In a typical Web services scenario, a business application sends a request to a service at a given URL using the SOAP protocol over HTTP. The service receives the request, processes it, and returns a response. The examples presented here are based on Sun Microsystems' Java Web Services Developer Pack 1.1 (http://java.sun.com/Webservices/Webservicespack.html). You will need to download and install JWSDP-1.1 on your machine to run the examples. Please read readme.txt carefully before running these examples. )

Using Multiple Web Services Within One Container
Consumers and providers of Web services are typically businesses, making Web services predominantly business-to-business transactions. An enterprise can be a provider of Web services and also a consumer of other Web services. For example, an HR department could be in the consumer role of Time Tracking and Insurance Tracking services provided by outsourcing companies, and a provider of a Payroll service to payroll processing companies. To be a provider of a Web service, a provider service doesn't have to be a service that processes just local application logic or fetches local legacy resident databases, but can very well work as simply an adaptor to other consumer Web services.

In Figure 1, many Web services are in the provider role (time tracking, insurance, and others), and one is in both the provider and consumer roles (payroll).

 

The Payroll service consumes the Time Tracking and Insurance service responses to produce a response requested by external businesses in the form of a Payroll service.

A number of business applications can utilize such a design approach (see Table 1).

 

Case Study: "Build Payroll Service"
Let's build a service layer as described above to produce payroll information. This service is based on the JAX-RPC API from Sun Microsystems. A similar service layer can also be built based on the JAXM API or by using a combination of two APIs. The "Payroll" service presented here is a client that utilizes the two consuming Web services, "Time Tracking" and "Insurance." It can also be built and published as a "producer" service that responds to a service request from a payroll-processing agency.

We will create the following components to build this service layer:

  • Insurance Service:
    - InsuranceIF: Insurance interface that defines the service methods
    - InsuranceImpl: Actual implementation of an InsuranceIF interface
  • Time Tracking Service:
    - TimesheetIF: Timesheet interface that defines the service methods
    - TimesheetImpl: Actual implementation of the TimesheetIF interface
  • Payroll Service (Client):
    - PayrollClient: Client that invokes the above services to generate final paycheck amount

    These services are deployed on the Tomcat server. The project is built using the Ant build system. Each service code resides in its own folder and each folder has the following set of files to build and deploy services on the Tomcat server:

  • build.xml: Ant build for each service and client (uses targets.xml from "common" folder)
  • config.xml: A configuration file read by the wscompile tool
  • jaxprc-ri.xml: A configuration file read by the wsdeploy tool
  • web.xml: A deployment descriptor for the Web component (a servlet) that dispatches to the service
  • build.properties: Property file for the ant build system

    Service Invocation Flow
    When it receives a request for gross pay, the payroll service invokes calls to get the total hours and the rate information from the Timesheet service. Then it makes calls to the Insurance service to get health, life, and disability insurance premium information. Finally, it calculates the gross pay and returns it as a response to the calling service.

     

    Let's discuss the Timesheet service further. We will not discuss the Insurance service since the implementation of both the services is very similar.

    The Timesheet interface (see Listing 1) defines two methods, getHours(int empId) and getRate(int empId). Both methods take empId as a parameter and return hours billed for the current period and the consulting rate of the employee. A simple implementation of the service is described in Listing 2.

    Listing 3 describes the configuration file for the Timesheet service needed for the wscompile tool and Listing 4 describes a configuration file read by the wsdeploy tool. The wscompile tool automatically generates the WSDL file when the service is compiled and deployed on the server. A complete listing of the WSDL file can be browsed when you visit the http://localhost:8080/time sheet-jaxrpc/timesheet and click the WSDL link on that page. JAX-RPC takes care of marshalling and unmarshalling the data returned by the service methods.

    Listing 5 describes the partial code of the payroll client that uses both Timesheet and Insurance services. As mentioned before, the payroll client can very well be built as a "Payroll" service that invokes Timesheet and Insurance services to compute employee salary.

    EAI/BPM Techniques
    Let's look at how we can use our business logic layer along with EAI (enterprise application integration) and BPM (business process management). We will look at these options briefly and then apply the concepts to our case study. Business Process Modeling Language (BPML) is the language of choice to implement complex business processes as declarative business logic.

    Today's enterprises also consider Web services while implementing BPM and EAI. Enterprises are exploring new avenues to automate business processes and share business data across the enterprise, allowing departments to be more efficient and productive. There is a dire need for a full duplex, bidirectional solution to share business processes seamlessly and exchange data among ERP, CRM, SCM, databases, data warehouses, and other important internal systems within the company. Enterprises have been using EAI technologies that enable unrestricted data sharing throughout networked applications within the company. EAI is the process of creating an integrated infrastructure for linking disparate systems, applications, and data sources across the corporate enterprise. The implementation of EAI technology has been an expensive affair with proprietary interface implementations to interact with various applications in real time. With the nightmare of managing disparate applications, data, data transformations, and proprietary interfaces, corporations are hoping SOAP-based architecture of Web services will be a breather.

    The emerging BPM breed of software provides analysis, design, automation, and optimization of business processes. They allow business managers and analysts to change the business process logic without changing the underlying IT programs. Many enterprises have applications where changing business processes involves engineers and programmers. BPM is the foundation of next-generation EAI. BPML is an XML-based business process definition language. The Business Process Management Initiative's (www.bpmi.org) mission is to promote and develop the use of BPM through the establishment of standards for process design, deployment, execution, maintenance, and optimization. BPMI.org develops open specifications, assists IT vendors in marketing their implementations, and supports businesses using BPM technologies. Enterprises are exploring Web services as a viable option for EAI and BPM solutions to leverage their existing software assets. The use of standard XML protocols makes Web services platform, language, and vendor independent, and an ideal candidate for use in EAI and BPM solutions.

    Declarative programming techniques are used to capture the business logic of your application as business rules and process models in the transaction logic and process logic layers. Transaction rules can be compiled into reusable components and executed within the Transaction Logic Engine. Process models are executed within the Process Logic Engine.

    In this case study, we've implemented business process logic for payroll functionality. A business analyst can easily change the business parameters (integration points) regarding time tracking and insurance data extraction without changing the application programs to implement new business logic. Figure 3 is a re-representation of the case study from a BPML point of view. Instead of integrating with time tracking and insurance Web services, as in the case study, we are now integrating with enterprise products based on EAI or BPM. These products provide integration points that can hook into their applications. Once the data is obtained from these products, it can be utilized in real time by building a BPML layer. Figure 4 is a process diagram for our Payroll layer.

     

     

    Conclusion
    Web services as stand-alone processes in themselves are powerful interfaces to complete B2B transactions. By building a logical layer over multiple Web services, you can leverage application-resident business logic in real time and take Web services technology to another level. Web services can also be built over enterprise products based on EAI and BPM. Business Process Modeling Language (BPML) is an emerging language to build such a logical layer over enterprise applications.

    Resources

  • W3C Web services architecture domain: www.w3.org/2002/ws
  • JWSDP-1.1: http://java.sun.com/webservices/webservicespack.html
  • The Business Process Management Initiative: www.bpmi.org
  • More Stories By Rajesh Zade

    Rajesh Zade has more than 13 years of experience in the computing field and has been working in various Java and e-Commerce technologies since 1996. He is currently chief technical architect for NetCliff, Inc., based in Santa Clara, CA.

    Comments (3) View Comments

    Share your thoughts on this story.

    Add your comment
    You must be signed in to add a comment. Sign-in | Register

    In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


    Most Recent Comments
    Editorial Staff 08/21/03 01:12:01 PM EDT

    We are looking into your comment regarding adding hyperlinks to the figures to make them easier to access for the future. The Listing 1 code is available through the Source Code link with the article.

    Joseph M. Chiusano 08/21/03 08:54:50 AM EDT

    This comment is regarding the format of the article rather than the content. It would be much easier for the reader if all references to figures were hyperlinked, so that the reader does not have to search for the proper figure from the series of figures on the right. I was also unable to find "Listing 1".

    U. N. Umesh 07/31/03 02:10:00 AM EDT

    The article provides a nice interface between technology and business aspects. The customer angle is also emphasized. For a related artcle on eMarketing, and what it has in store in the future, see

    http://www.digital-web.com/interviews/interview_2003-06b.shtml