Loosely typed interfaces – The Normalizer Pattern and Oracle SOA Suite

When getting two or more systems working together, the making a connection part is generally the easiest, identity propagation is a bit trickier, but many times, the syntax and semantics of one system is at odds with another one. Over the decades this has been manifest in many ways and thankfully there are tools and techniques to work through them. A collation of such techniques is Enterprise Integration Patterns. The book, along with the associated website, is worthy of a dedicated article or two, and is not the real subject of this article. One message transformation pattern the book describes is the Normalizer Pattern where different formats for essentially the same object are catered for.
An example where this form of message translation becomes necessary is when using a service with a loosely typed interface. This can often happen when an existing system or utility (such as a batch / command processor) gets exposed as a web service. The request / response payload is little more than a collection of key / value pairs. There are a couple of ways to cater for this using Oracle SOA Suite 11g which I will outline in this article. One has full tool support. The other, a solution using XSLT, is not fully supported, but has an advantage in that the XSLT can be used both with the BPEL and Mediator components.

Troublesome Payloads
The challenge is to get something that is strongly typed into something that is loosely typed

Strongly Typed Loosely Typed


Furniture
Pam Beech
50000
20000
47000


NAME
Furniture


MANAGER
Pam Beech


BUDGET
50000


SPENT
20000


COMMITTED
47000

Now this is quite a simple example and the real world has a lot more complicated cases out there. Ones that would involve number formatting, character encoding, attribute concatenation, and so on. For the purposes of this exercise however, it is ideal to illustrate the point. All the files in this example are free and available for you to use, modify or incorporate into your own solution as you see fit. The example was produced and tested using Oracle Fusion Middleware 11.1.1.2.0. That is JDeveloper Studio 11.1.1.2.0 and WebLogic Server 11gR1. To reduce the number of files and dependencies involved, the example is a simple service (BPELProcessExample.wsdl) that takes a strongly typed request payload and returns a loosely typed response payload. The SOA composite project contains two BPEL processes that provide slightly different implementations for this same WSDL.

BPEL assign with copy and insertAfter
You can cater for the key / value pair structure by repeatedly appending a new ‘property’ element and then, using an XPATH predicate to specify which ‘property’ element is the target, copying the desired values. In the BPEL process this can all be done in a single ‘assign’ command, using the insertAfter instruction from the Oracle BPEL extension library. The BPEL designer supports this approach, and it is used extensively in production systems around the globe. It can get difficult to maintain and hard to read if the payload is large though. If dealing with a large payload see if you can split the copy / insertAfter instructions into two or more ‘assign’ commands. Ideally, you would give these ‘assign’ commands logical names such as ‘assign_part_1_admin_details’ and ‘assign_part_2_finance_details’. What is a large payload in this case then? Well, I would say that if you have more than 10 key value pairs you should be seriously thinking about splitting them up and if you have more than 20, you should be definitely splitting them up. Remember, you might be familiar with the structure and understand how it is constructed, but what about the college graduate brought in by the consulting firm in a months time, or even you having to come back to this in 6 months time? Go on, make the maintenance a bit easier for everyone and break that assign behemoth into manageable chunks!

BPEL transform with XSLT
If experienced in dealing with XML documents then this approach will probably be very familiar to you. Extensible Stylesheet Language Transformations is used to convert XML data into some other format, which may also be XML data. In this case the stylesheet explicitly describes the target XML structure, making it somewhat easier to read than the BPEL assign approach described earlier. For example…



MANAGER






The ‘client’ is a namespace prefix for the schema and in this SOA composite example the request and response happen to be defined in the same schema. This is easier to read, even if one is not all that familiar with XSL. For large payloads it is not necessary to split up the transformation as one might consider for the BPEL assign, but it could be done. The single transformation file could have a whole set of templates. However, the XSL Mapper does not support this approach yet, so if using this approach you will have to work in the Source editor, not the Design mode. Since this is using XSLT, the same XSL file can be used by the Mediator too, so it is not only a BPEL solution.

Which one is right for me?
As one can see from the diagrams there is not much difference in the BPEL designer between the two examples and the decision on which technique to use would be based on factors which are different from company to company, but clearly use of the XSL mapper is an important factor.
The complete example application with SOA composite is available at http://sites.google.com/site/soastation/soastation_looselytyped_normalizer.zip

Oracle SOA Suite Developer’s Guide

Service-Oriented Architecture (SOA) is not about technology, although technology is used to implement it. The principles of reliability and accommodating unexpected changes at a manageable cost can be applied equally in any programming language. However, as with most things in life, not just software development, it is easiest to use a model that is supported by tools and inter-operable (the ability of two or more systems or components to exchange information and to use the information that has been exchanged). A standards-based Service-Oriented Architecture (SOA), is such a model that enables IT infrastructure is continuously adapted to keep up with the pace of business change.

Matt Wright and Antony Reynolds have just published a book Oracle SOA Suite Developer’s Guide that provides a best practice guide to using the Oracle SOA Suite for building a real world applications. This book bridges the gap between SOA theory and the Oracle SOA Suite Manuals and is based on the experience of implementing SOA across a number of organisations in EMEA and APAC. It is a book of three parts. The first section of the book provides detailed coverage of all components of the SOA Suite, namely OSB, BPEL, Rule, BAM and OWSM. The second section addresses the common question: “What is the best way to combine / use all of these different components to implement a real-world SOA solution?”. Using a working example of an online auction site, it leads you through key SOA design considerations in implementing a robust solution that is designed for change. Though the examples in the book are based on Oracle SOA Suite 10.1.3.4 the book will still be extremely useful for anyone using 11g. The final section addresses non-functional considerations and covers the packaging, deployment, and testing of SOA applications; it then details how to use Web Service Manager to secure and administer SOA applications.

I’m sure this book will continue to be relevant in years to come to. Unlike other technical books, this one does more than just explain “how” to do A, B, and C, but goes to great lengths to explain the concepts. As a software developer it is vital to understand why we were doing what we were doing, so that we know which principles to apply in different situations.

Getting requestor’s IP address through Oracle WSM

Oracle Web Services Manager (OWSM – some people pronounce it as ‘Awesome’) plays an important roll in Oracle’s contribution to SOA governance. Put simply, it brings better control and visibility over how, when and by whom, web services are invoked. OWSM, which is a key product in the Oracle SOA Suite, was voted one of the best security solutions by SYS-CON Media, the world’s leading i-technology media and events company in it’s 2007 SOAWorld Readers’ Choice Awards.

Apart from the predefined policies, OWSM provides an extensibility point to define a custom policy step that can be executed as part of the request or response pipeline. There is an Oracle by Example (OBE) tutorial available that provides details for creating a custom step. The custom step authenticates the user against a fixed set of username/password credentials configured in the policy step pipeline.

You can go one step further and check IP address of the requesting client by accessing the HttpServletRequest in the MessageContext in the execute operation of your custom step code.

import com.cfluent.pipelineengine.container.MessageContext;

((HttpServletRequest) ((
MessageContext) messageContext).getProperty(“javax.servlet.request”)).getRemoteHost()

Remember that if there are proxies or NAT address translations between the requester and the provider you won’t know the real source IP. Clearly this only works for HTTP based requests. However, a similar approach could be used for JMS.

It is worth mentioning Vikas Jain’s Web Services Security blog which is a treasure trove of useful information on OWSM.

Announcing: Technology Preview for SOA Suite 11g

Within the past week the 3rd technology preview of JDeveloper 11g was made available on the Oracle Technology Network (OTN) website. For me, the most significant aspect of this preview is that it includes a preview of the long awaited SOA Suite 11g which supports the Service Component Architecture (SCA) specification. This Technology Preview release of Oracle SOA Suite 11g showcases the support for SCA through the new composite assembly editor in JDeveloper as well as a unified service engine foundation for the full set of SOA Suite components.

The SOA Suite 11g software is available within the JDeveloper 11g environment – yes, that’s right! You only install JDeveloper and you also get the SOA Suite server side for deploying your 11g composite applications!

Go to OTN for instructions and details for the SOA Suite 11g Technology Preview. Be sure to read the Quick Start & Installation Guide and remember that you will need an Oracle database installed. This one is definitely worth taking for a test drive!

Oracle Lite and SOA Suite

The Oracle SOA Suite bundles a number of Oracle products (BPEL Process Manager, ESB, Oracle Business Rules and Web Services Manager) to provide complete set of service infrastructure components for building, deploying, and managing SOAs. For the windows platform it also comes with slimmed down version of Oracle Lite, an embedded database.

Why Oracle Lite?
Oracle Lite has a lot of great features including data synchronisation, device management, as well as support for SQL92 and ACID transactions amongst other things. It is the embedded relational database features that are used for the ‘basic’ installation of SOA Suite on windows. Antony Reynolds recently posted a great article on basic and advanced installation options which really puts an emphasis on the fact that Oracle Lite is intend to get you developing fast and not for production environments.

In the development environment the SOA Suite will use Oracle Lite under the hood and generally you don’t need to access this database. Of course, there are always the odd occasions when you do, such as tracing an error, or doing an upgrade.

Connecting to Oracle Lite
Over the summer a patch set was released to upgrade Oracle Application Server 10.1.3.1 (SOA Suite) to 10.1.3.3. The patch (#6148874) is available on metalink. The post installation steps involve running a database script. Since the SOA Suite is distributed with a slimmed down Oracle Lite there is no Mobile Client Workspace, i.e. webtogo web app, to manage the database, so the Mobile SQL Client is your easiest option.

Mobile SQL Client ($ORACLE_HOME\Mobile\Sdk\BIN\msql.exe) is used to connect to an Oracle Lite version 9 and upwards database. For earlier versions SQLPlus can be used. The version distributed with SOA Suite is 10.2.0.2. The usage is quite like SQLPlus:

msql system/manager@jdbc:polite:

For the SOA Suite there are three databases: orabpel, oraesb, orawsm. Connecting to the database used by Oracle BPEL Process Manager looks like this:

D:\msql system/manager@jdbc:polite:orabpel

Oracle Lite MSQL Version 10.2.0.2.0
Copyright (c) 1997, 2005, Oracle. All rights reserved.

Connected to: Oracle Lite ORDBMS
Database Name: ORABPEL (Read Write)
Database Version: 10.2.0.2.0
Auto Commit: off
Driver Name: oracle.lite.poljdbc.POLJDBCDriver (OLite 4.0)

SQL>

Alternatives
Another option to using Mobile SQL Client is to use Oracle SQL Developer a free graphical tool for database development. Just use the same JDBC connection properties that you can find in the Enterprise Manager, and ensure the olite*.jar files (in Mobile/SDK/bin) are in the classpath.

Summary
Oracle Lite is OK for a small SOA Suite development environment and even the slimmed down version that is distributed provides access to the databases via the Mobile SQL Client.