SOA Integration
SOA Integration
Enterprise Application
Integration
247
248 Integration Requirements and Scenarios
bining two divergent information technology (IT) systems. Not only are the IT
systems different, but, as a further challenge, they each may have standardized on
using different integration technologies within their respective environments.
Emerging Web services standards are another factor driving Web services-based
EAI. These standards are making it possible to integrate heterogeneous systems
easily and cost effectively.
In today’s environment, a typical enterprise has a multitude of existing appli-
cations running on diverse platforms and operating systems. Although these appli-
cations may very well rely on the same or similar data, they keep that data in
different formats. Thus, the integration problem encompasses both data and
system platforms.
These are but a few examples of the complexities that enterprise application
integration must address. Not only must EAI handle integrating applications, it
must also address integrating data and technologies so that enterprises can easily
share business processes and data.
Using several scenarios, this chapter illustrates key integration considerations.
It describes the J2EE 1.4 platform technologies that help with integration and pre-
sents some integration design approaches and guidelines.
business, especially since its existing customers may also buy products through
the online store. Adventure builder enterprise also wants to leverage its customer
service department and have these same specialists service both types of custom-
ers: store front as well as online. Adventure builder enterprise expects to include
additional databases relevant for the Web site only.
This scenario illustrates an application and data integration problem. The
enterprise’s existing databases store information needed by the e-store, which may
need to update these databases. The databases have existing security settings, plus
protocols for transactions. The vendor for the CRM system may have provided a
J2EE connector that could be used to plug the CRM system into the enterprise’s
J2EE application server. However, the order processing system, since it is home-
grown, may have no such support.
Figure 6.1 illustrates the scenario of this application with respect to the EISs
that it uses. This example scenario touches upon many of the integration require-
ments that pertain to all enterprises. Because it is open to anyone on the Internet,
the adventure builder Web site may potentially have a large number of users,
making scalability and performance important issues. Security is an important
consideration, since adventure builder’s Web site handles customer data that it
must keep private. The enterprise has the further challenge of ensuring that its
legacy systems are not stretched beyond their capabilities and that heterogeneous
platforms may host the EIS systems.
The enterprise relies on an order fulfillment center to process orders placed
through the e-store Web site. A separate department owns the order fulfillment
center, and it uses its own set of databases separate from the e-store’s Web site. To
keep the two data models decoupled, orders flowing between the e-store and the
order fulfillment center are kept in XML format. Communication is also asyn-
chronous, allowing clients to continue their own work while an order is processed.
In essence, the order fulfillment center initiates a business process whenever it
receives an order. The business process, following a set of automated rules, inter-
acts with several systems in a workflow to complete or fulfill the order with no
human intervention. Part of the workflow includes sending confirming e-mails to
customers and keeping records for administrative reports.
Chapter 6 Enterprise Application Integration 251
Order processing
database
Customer
Web site Order processing
system
(legacy)
Adventure
Builder travel
agency
Suppliers
CRM system
(legacy)
Web site
database
CRM database
The order fulfillment center interacts with external business partners to com-
plete its workflow. For example, the order fulfillment center might rely on a sepa-
rate credit card billing service to process its customer billing. Some of its products
may be supplied directly by another vendor. The order fulfillment process initiates
multiple business processes for each external business with which it interacts.
Let’s look at a different integration scenario. A human resources application,
designed for internal use only, may have a similar scenario to an e-store, since it
concerns a new application that uses existing enterprise assets. However, the
application’s internal use limits the scalability, performance, and security con-
cerns. The principal concerns with internal applications such as this are fast deliv-
ery time, platform heterogeneity, and the capacity to grow the application and
support multiple types of clients as the enterprise expands. The application may
252 J2EE Integration Technologies
also want single sign-on for users across various security domains, but, at the
same time, permit access only to employees whose proper access privileges
adhere to company-wide rules.
Internal applications may also provide some limited mobile functionality; that
is, they need to be accessible from mobile devices such as PDAs and cellphones.
For example, a travel expense tracking application may want to allow employees
who are on the road to keep track of their expense records. Likewise, enterprises
whose departments are geographically scattered may find it more efficient for
employees to use the Internet for internal communications. Web service interfaces
are particularly useful in these situations, although there are the additional con-
cerns of distributed and multiple security domains.
Often, systems developed for internal use rely on home-grown legacy sys-
tems. While systems bought from third-party vendors may be integrated using
standard connectors supplied by their vendors or third parties, this is not true for
homegrown systems. These homegrown, or one-off, applications must still be
integrated with other applications in the enterprise and accessed from a Web
browser.
• JDBC—Developers can use the JDBC APIs to access relational data in a tab-
ular form.
• Enterprise JavaBeans container-managed persistence (CMP)—Developers use
container-managed persistence to do object-relational (O/R) mapping. By
mapping database table data to Java objects, developers can deal with an object
view of the data rather than a tabular, relational view. CMP also encapsulates
the objects into higher-level managed components with transactional and secu-
rity features.
• Java Data Objects (JDO)—An O/R mapping technology that generates Java
classes as opposed to components. Note that JDO is optional in the J2EE 1.4
platform. Since it is optional, your application server may not support JDO, or
it may support JDO in a nonstandard manner.
6.2.1.1 JDBC
The JDBC API defines a standard Java API for integration with relational data-
base systems. A Java application uses the JDBC API for obtaining a database con-
nection, retrieving database records, executing database queries and stored
procedures, and performing other database functions.
Many application component providers use the JDBC API for accessing rela-
tional databases to manage persistent data for their applications.
The JDBC API has two parts: a client API for direct use by developers to
access relational databases and a standard, system-level contract between J2EE
servers and JDBC drivers for supporting connection pooling and transactions.
Developers do not use the contract between J2EE servers and JDBC drivers
directly. Rather, J2EE server vendors use this contract to provide pooling and
transaction services to J2EE components automatically. Note that, according to
the JDBC 3.0 specification, the JDBC system-level contracts can be the same as
the Connector architecture system contracts. Conceptually, JDBC drivers are
254 J2EE Integration Technologies
message A Client
Topic
<Subscriber>
me
Publish-Subscribe ssa
ge
sh A Messaging System A
bli ge
pu ssa
me Client
<Subscriber>
Client
<Sender>
se
m nd
es
sa
g eB
message B Client
Queue
<Receiver>
When used for integration, an enterprise very likely requires that all partici-
pating EIS systems communicate with each other by sending messages via the
messaging system. As a result, enterprises typically standardize on one vendor for
their MOM system, and they use that vendor’s adapters to accommodate their
various EISs. In return, enterprises using messaging systems gain the benefits of
asynchronous messaging calls: Messages are queued and delivered when the
target system is available without constraining the sending system. The asynchro-
nicity of messaging systems means that communicating applications need not be
currently running to receive messages. This protects the communicating applica-
tions from system failures and other types of partial outages, conditions that are
not uncommon in network situations.
Messaging systems also bring a dynamic quality to EIS systems. Components
can be added or removed to the network without affecting other systems. Systems
do not need to have their throughputs perfectly match since they can interact with
the messaging system at their own pace. For example, if one application sends
messages more rapidly than the receiving application can retrieve these messages,
the messaging system keeps these messages in the queue indefinitely. As a result,
good overall throughput is achieved since each part of the system can work at its
optimum capacity.
Furthermore, messaging technology is considered a fairly mature technology.
Most MOM systems provide a number of quality of service features, such as reli-
able once and only once delivery, load balancing, scalability, fault tolerance, and
transactional support.
However, the proprietary nature of MOM systems results in some significant
disadvantages. Since they use proprietary protocols over the network, it is usually
more difficult to mix and match MOM products from different vendors. Although
messaging systems decouple the sender and receiver and permit communicating
parties to run on different hardware and software platforms, they fall short of
achieving true interoperability because they tie developers to their proprietary
APIs to send and receive messages. As a result, application developers must cus-
tomize their applications for different MOM systems.
they are stateless, any instance of a matching type of message-driven bean can
handle the message.
Implementing a message-driven bean is straightforward. The bean developer
extends the javax.ejb.MessageDrivenBean interface and a message listener inter-
face for the bean—the message listener interface corresponds to the enterprise’s
messaging system. For enterprises using JMS, the developer extends the
javax.jms.MessageListener interface. A developer may embed business logic to
handle particular messages within the MessageListener methods. For example,
when a message-driven bean consumes JMS messages, the developer codes the
message-handling business logic within the onMessage method. When a message
appropriate for this bean arrives at a message destination, the EJB container
invokes the message-driven bean’s onMessage method.
With message-driven beans, you can make the invocation of the bean part of a
transaction. That is, you can ensure that the message delivery from the message
destination to the message-driven bean is part of any subsequent transactional
work initiated by the bean’s logic. If problems occur with the subsequent logic
causing the transaction to roll back, the message delivery also rolls back—and the
message is redelivered to another message-driven bean instance.
Container-
component
contracts Application
Container
Component
Connection
pool manager Transaction Application
manager contract
Lifecycle
manager Work
manager
EIS-specific
interface
Enterprise
J2EE Application Server Information
System
The most recent release (version 1.5) of the Connector architecture expanded
the capabilities of resource adapters. This release expanded the transaction
support for a resource adapter. Previously, a transaction had to start from an enter-
prise bean on the J2EE application server, and it remained in force during opera-
tions on the EIS. Now, transactions can start on the EIS and be imported to the
application server. The J2EE Connector architecture specifies how to propagate
the transaction context from the EIS to the application server. The Connector
architecture also specifies the container’s role in completing a transaction and
how it should handle data recovery after a crash.
The current version also specifies additional system-level contracts to the
initial three contracts just noted. These new contracts are:
inhibit server shutdown and impact performance. To alleviate this problem, the
work management contract enables the application server to pool and reuse
threads, similar to pooling and reusing connections.
In addition, the work management contract gives resource adapters more flex-
ibility for using threads. The resource adapter can specify the execution con-
text for a thread. The contract allows a requesting thread to block—stop its own
execution—until a work thread completes. Or, a requesting thread can block
while it waits to get a work thread; when the application server provides a work
thread, both the requesting and work threads execute in parallel. Yet another
option, a resource adapter can submit the work for the thread to a queue and
have it execute at some later point; the adapter continues its own execution
without waiting further. Thus, a resource adapter and a thread may execute in
conjunction with each other or independently, using a listener mechanism, if
need be, to notify the resource adapter that the work thread has completed.
• Lifecycle management contract—Enables an application server to manage the
lifecycle of a resource adapter. With this contract, the application server has a
mechanism to bootstrap a resource adapter instance at deployment or at server
startup, and to notify the adapter instance when it is undeployed or when the
server is shutting down.
❐ The integration layer defines the interface between the EIS systems and new
applications, thus exposing an EIS system to an application.
❐ An integration layer needs to be the stable point in your system—the fixed
standard against which new applications are programmed. While both the new
application and the existing EIS may change, the integration layer should re-
main the same. Otherwise, changes in one place will require changes to numer-
ous dependent systems.
264 Integration Design Approaches
Application 1 EIS A
Application 2 J2EE
Application
Server Relational
database
Application 3
EIS B
Integration approaches vary, and often the situation dictates the best approach.
In some situations, the integration approach is fairly obvious. For example, when
a client requires a tightly coupled interaction with a relational database, clearly the
JDBC API is the design strategy to use. Similarly, another design strategy uses the
J2EE Connector architecture for data integration with non-relational databases.
These two design strategies are particularly appropriate when the client requires
an API for connecting, querying, and updating a database with transactional
semantics. Other situations require you to combine technologies to meet the inte-
gration requirements. You might use connectors on top of a non-relational data-
base, but then, based on the client requirements, you might add a Web service
layer on top of the connector.
It is helpful to view the process of formulating an integration approach as
three separate tasks (each requiring a design and implementation phase):
• Decide on the integration layer, including where it should be located and what
form it should take. With the J2EE platform, various integration layers are pos-
sible, including connectors, enterprise beans, JMS, and Web services. Remem-
ber that you want the integration layer to be such that other applications or
systems can evolve easily.
• Decide how to adapt each EIS to the integration layer.
• Decide how to write new applications against these integration layers.
Chapter 6 Enterprise Application Integration 265
Keep in mind that an important reason for using an integration layer is the ser-
vices it provides for distribution. Usually, EISs are located on different physical
machines, or they may be run as separate processes. To integrate these EISs, you
need to use a distributed technology. J2EE application servers are an excellent
choice for integration because they can handle multiple protocols for distributed
computing: Internet Inter-ORB Protocol (IIOP), messaging, HTTP and Web ser-
vices. In addition, J2EE application servers can handle native EIS protocols
through connectors. These native protocols include proprietary protocols used by
ERP and database vendors, among others.
Figure 6.5 shows the integration design approaches that are possible with the
J2EE technologies.
Note: This figure uses dashed lines to represent asynchronous calls, such as
sending a JMS message. The solid lines show synchronous calls, which are made
either through EJB or Web service APIs. The three applications, which are shown
on the left side of the diagram, are new EAI applications that you might be writ-
ing. The right side of the diagram shows some of the existing EIS systems that
need to be integrated with the EAI applications.
.
Connector
EJB/JMS as
EJB
Application 2 J2EE
integration layer
Application
Service
Server
Web
JDBC/CMP
Relational
database
MDB
EIS B
Since it requires very tight coupling with EIS A, EAI application 1 bypasses
the J2EE application server but reuses the connector layer. Application 2 needs to
use some business logic present in the application server. As a result, it does not
want to access the EIS directly. Application 2 instead uses a combination of syn-
chronous and asynchronous calls to the EJB tier. These calls (to enterprise beans
and message-driven beans) access EIS A and the relational database through
JDBC, EJB container-managed persistence, or connectors. EIS B also generates
asynchronous messages for implementing the business logic, and these messages
must be delivered to a message-driven bean. Application 3 uses the least tightly
coupled interface, Web services, and it accesses available functionality through a
Web service interface. The Web service internally uses the business logic stored in
the J2EE application server. (In the next sections we take a closer look at these
different EAI design approaches and then provide some guidelines for implement-
ing these approaches.)
Let’s see how you might apply this strategy to the adventure builder enter-
prise. The adventure builder enterprise decides to use several layers for
integration:
Developers who use the Web service approach for integration can leverage the
advantages of Web services. Developers can write new enterprise applications
with any technology that supports Web services, and the applications may be run
on a variety of hardware and software platforms. However, this approach falls
short when the new applications have certain additional requirements, such as
transactional semantics or stringent security requirements. We discuss how to
handle these issues in subsequent sections.
The adventure builder application is a good example of the Web services
approach. As noted, the adventure builder enterprise uses Web services for inte-
grating its supply chain. (Chapter 8 discuss the exact structure of the application,
but here we highlight those details that pertain to integration.) The adventure
builder architects decide, in consultation with the suppliers, on the schemas for the
documents that they intend to exchange. (See “Designing Domain-Specific XML
Schemas” on page 131.) Since their business depends on this exchange of docu-
ments—the adventure builder application sends purchase orders to various suppli-
ers who fulfill adventure requests, and, in turn, the suppliers invoice adventure
builder—the adventure builder enterprise and the suppliers need to agree on
schemas that describe the content of these documents. For example, a lodging
supplier might use an invoice document schema. Code Example 6.1 shows an
example document corresponding to that schema. Similar schemas are defined for
other kinds of suppliers, such as activity and airline suppliers.
Similarly, the architects standardize on the WSDL to use for invoices when
fulfilling an order. Suppliers, such as airlines, hotels, and activity providers, use
these schemas and WSDL descriptions when interacting with the adventure
builder enterprise. Code Example 6.2 shows the WSDL for the Web service end-
point to which the suppliers send their invoices.
The WSDL shown in Code Example 6.2 provides a single operation,
submitDocument, which has a single xsd:anyType parameter representing the
invoice XML document and which returns a single string value indicating a con-
firmation. The use of xsd:anyType enables an endpoint to receive multiple types
of invoice documents with one method. See “Exchanging XML Documents” on
page 107. A WSDL document normally begins with the type definitions that it
uses, such as the exception type InvalidDocumentException. (For brevity, the
code sample omits these type definitions.) The WSDL code then describes the
SOAP messages used in the SOAP request and reply calls that correspond to the
submitDocument method. It also describes a WSDL port corresponding to the
JAX-RPC interface for receiving invoices, plus it binds the port to the HTTP pro-
tocol and indicates the RPC-literal binding. Finally, the WSDL code defines the
name of the service and the URL at which the service is available. (For a more
detailed explanation of a WSDL document, see “Web Services Description Lan-
guage” on page 36.)
</operation>
</portType>
<binding name="BrokerServiceIntfBinding" type=
"tns:BrokerServiceIntf">
...
</binding>
<service name="WebServiceBroker">
...
</service>
</definitions>
Although you can modify the EIS systems that participate in Web service
interactions to export the Web service interfaces, a better approach uses a J2EE
connector to plug the EIS system into the J2EE application server. The connector
by its nature does not intrude on the EIS. This latter strategy takes advantage of
the capabilities of the J2EE server. Among other advantages, using connectors
allows the transactional and security contexts of a J2EE application server to carry
forward to the EIS application. Plus, the EIS can use the thread pools of the appli-
cation server. In conjunction with connectors, you use JAX-RPC from the J2EE
application server to expose a Web service interface. See Figure 6.6.
❐ To expose a Web service interface for an EIS, use JAX-RPC in front of a con-
nector.
J2EE
Application
Server
Web or EJB
JAX-RPC
endpoint
Connector
Client EIS
component
(business logic)
For example, the adventure builder enterprise wants to use Web services to
integrate its existing CRM system, which provides services to manage customer
relations, to process orders. The department that owns the CRM module not only
wants to maintain control of the software, it wants to use a generic interface that
can handle user requests from multiple sources (Web site, telephone, OEM chan-
nels, and so forth). Web services are the best way to create such a generic inter-
face, for these reasons:
• Web services establish clear, defined boundaries. Since Web services can pro-
vide an interface with clear, defined boundaries of responsibilities, the CRM
department has the responsibility to only maintain the endpoint and publish a
WSDL describing the endpoint.
• Web services provide controlled access. Outside requests to the CRM must
come in through the service interface, and the CRM department can apply its
access control parameters to limit access, plus it can log each access.
• Web services support multiple platforms. Because it does not control the hard-
ware and software platforms other departments use, the CRM department can
accommodate any platform by using Web services.
• The current generation of Web services is best suited for applications with a
limited need for transactions and security. The main purpose of the CRM sys-
tem is to allow status queries on existing orders. As such, it has little need for
transactions. It also has limited need for security, since all access to the module
happens within the corporate firewall.
Developers have a choice of endpoint types for implementing the Web service
representing the EIS: either an EJB service endpoint or a Web-based JAX-RPC
service endpoint. Solely from an integration point of view, either type of endpoint
works well since Web and EJB components can both directly use JDBC and J2EE
connectors. For example, the adventure builder enterprise receives invoices using
an EJB service endpoint, as well as JAX-RPC service endpoints for other func-
tions.
Returning to the CRM problem, the adventure builder enterprise could use a
small J2EE application that uses a J2EE connector to connect to the CRM system.
Such an application needs to have a JAX-RPC endpoint to expose the required
Web service functionality.
Today, since many EIS vendors are providing built-in Web services support,
developers can use connectors and leverage this support directly to avoid writing a
Chapter 6 Enterprise Application Integration 271
JAX-RPC wrapper. If you choose to follow this path, ensure that the EIS vendor
provides a WS-I Basic Profile-compatible Web service. If the vendor does not,
consider writing an adapter layer yourself to handle any differences. This
approach may require upgrading your EIS system to a new software version, a
risk you may not want to take. In such cases, consider using the recommended
connectors and JAX-RPC approach.
❐ Consider using the built-in Web services support provided by the EIS vendors
to avoid writing additional interfaces.
If you want to provide a simple isolation layer, you should consider writing a
data access object, or DAO class, to hide the internal details of the EIS. A data
access object encapsulates access to persistent data, such as that stored in a data
management system. It decouples the user of the object from the programming
mechanism for accessing the underlying data. It can also expose an easier-to-use
API. Typically, you develop a data access class for a specific business function or
set of functions, then client applications use these classes. Another common use is
to layer data access objects on top of connectors, or resource adapters, thus isolat-
ing applications from the details of the connector interactions. Often, each
resource adapter interaction has a corresponding data access object, whose
methods pass input records to the adapter as parameters and return output records
to the client application as return values.
Using a connector reduces the complexity of the integration layer. Note that
when using the connector approach, the EAI application is tightly coupled with
the EIS since the application directly uses the data model and functionality of the
EIS. Since there is minimal layering, it also increases performance. However, it is
an approach that works best when the integration problem is small in scope. Since
it does not put into place a true integration architecture, this approach may limit
the ability to scale the integration layer as the enterprise grows. Given these
advantages and disadvantages, consider using this approach as a basic building
block for other strategies.
relational or binary from an EIS, you may want to consider other solutions, such
as using the J2EE Connector architecture, which provides a metadata facility to
dynamically discover the data format in the EIS.
Table 6.1 compares these approaches for different integration problems and
indicates the approaches best suited for these integration problems. The adventure
builder enterprise uses Web services for partner and inter-department interactions,
and the enterprise beans with JMS (EJB/JMS) approach for intra-department
interactions.
When you use the EJB container-managed persistence technology, you also can
rely on the EJB container’s security features to control access to the data. You also
leverage the performance benefits of the EJB container-managed persistence
engine, which uses data caching to improve performance. Finally, by using these
technologies, you can take advantage of the mapping tools that come with them.
The other option for representing relational data is to create a generic layer to
hold the data. For this approach, you use JDBC APIs to handle data from rela-
tional data sources. The JDBC RowSet technology, in particular, makes it easy to
access relational data in an efficient manner. (Keep in mind, however, that JDBC
RowSet technology is not yet standard in the J2EE platform.) The RowSet technol-
ogy, through the WebRowSet feature, gives you an XML view of the data source. Its
CachedRowSet capabilities lets you access data in a disconnected fashion, while
the FilteredRowSet functions give you the ability to manage data in a discon-
nected manner, without requiring heavyweight DBMS support. By using a generic
layer to hold data, you have a simpler design, since there is no real layering, and
you avoid the conceptual weight of a formal data model. This approach may have
better performance, particularly when access is tabular in nature (such as when
selecting several attributes from all rows that match a particular condition).
Connectors let you plug in non-relational data sources to the J2EE environ-
ment. For non-relational systems that do not have ready-made connectors avail-
able, such as home-grown systems, you need to write your own connector. See
“Integrating Custom Legacy Systems” on page 283.
❐ A good strategy for data transformation is to use the canonical data model.
An enterprise might set up one canonical data model for the entire enterprise
or separate models for different aspects of its business. Essentially, a canonical
data model is a data model independent of any application. For example, a canon-
ical model might use a standard format for dates, such as MM/DD/YYYY. Rather than
transforming data from one application’s format directly to another application’s
format, you transform the data from the various communicating applications to
this common canonical model. You write new applications to use this common
format and adapt legacy systems to the same format.
XML provides a good means to represent this canonical data model, for a
number of reasons:
unambiguously define the data model. Before XML, many times canonical
data models were established but never documented by their developers. If you
were lucky, developers might have described the model in a text document. It
was easy for such a document to get out of sync with the actual types used by
the model.
• XML schemas are enforceable. You can validate an XML document to ensure
that it conforms to the schema of the canonical data model. A text document
cannot enforce use of the proper types.
• XML is easier to convert to an alternate form, by using declarative means such
as style sheets.
• XML is both platform and programming-language neutral. Hence, you can
have a variety of systems use the same canonical data model without requiring
a specific programming language or platform.
This is not meant to imply that XML is perfect, since there are some disadvan-
tages to using XML to represent a canonical model. For one, to use XML you
need to either learn the XML schema language (XSL) or use a good tool. Often,
transforming XML requires you to use XSL, which is not an easy language to
learn, especially since XSL is different from traditional programming languages.
There are also performance overheads with XML. However, for many enterprise
settings (and especially for integration purposes) the benefits of using XML out-
weigh its disadvantages, and the benefits of XML become more significant when
you factor in future maintenance costs.
Code Example 6.3 shows an XML document representing invoice informa-
tion. This might be the canonical model of an invoice used by the adventure
builder enterprise. Since this document is published internally, all new applica-
tions requiring this data type can make use of it.
<bpi:SupplierId>LODGING_INVOICE</bpi:SupplierId>
<bpi: status>COMPLETED</bpi:status>
</bpi:Invoice>
It is usually a good idea to provide the schema for the canonical data model.
By having the schema available, you can validate the translated documents
against it and newer applications can use the schema to define their own models.
Code Example 6.4 shows the XSD schema file for this invoice information.
Example 6.5 shows the equivalent Java classes for the canonical model of invoice
information.
Code Example 6.5 Java Class Equivalents for Canonical Invoice Information
Once the XML is defined, you can also use tools such as JAXB to generate the Java
classes. (See “Flexible Mapping” on page 148.)
After establishing a canonical data model, you must devise a strategy to
convert any alternate data representations to this model. Because it plugs its enter-
prise systems—billing, order processing, and CRM—in via an application server,
the adventure builder enterprise exposes the canonical data model only through
the external interfaces exposed by the application server. That is, only those com-
ponents with external interfaces—Web service applications, remote enterprise
beans, and so forth—expose the canonical data model. Since the external world
needs (and sees) only the canonical data model, the adventure builder enterprise
must transform its internal data representations—which have their own data
model devised by its various EISs—to this same canonical model.
The data translation between the internal and external representations can be
done before the data goes from the EIS into the application server—that is, the
application server internally uses the canonical data model, which is generally
recommended. Or, the data translation can take place just prior to sending the data
out to the external world—that is, the application server uses the various EISs’
native data representations. Sometimes the business logic necessitates this latter
approach because the logic needs to know the precise native format. The transla-
tion is accomplished in one of two ways:
1. Use XSL style sheets to transform these alternate data representations, either
when data comes in or when data goes out. XSL style sheets work for XML-
based interfaces. In this approach, the application server internally uses the EIS
280 Data Integration Guidelines
native formats and the translation happens just before the data either goes out
to the external world or comes in from the outside.
2. Use a façade approach and do programmatic object mapping in the DAO layer.
That is, you set up a DAO to connect an EIS to the application server. Write
the DAO so that it exposes only the canonical data model and have it map any
incoming data to the appropriate internal data model. Since this approach con-
verts incoming data to the canonical form when the data arrives at the applica-
tion server, the business logic internally uses the canonical data representation.
To understand the XSL style sheet approach, let’s consider how the adventure
builder enterprise receives invoices from various suppliers. In adventure builder’s
case, various suppliers submit invoices, and each supplier may have a different
representation (that is, a different format) of the invoice information. Furthermore,
adventure builder’s various EISs may each have a different representation of the
same invoice information. Code Example 6.6 shows an example of a typical sup-
plier’s invoice.
<xsl:stylesheet version='1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:bpi='http://java.sun.com/blueprints/ns/invoice'>
<xsl:template match="text()"/>
<xsl:template match="@*"/>
<xsl:template match="bpi:Invoice">
<bpi:Invoice xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://java.sun.com/blueprints/ns/invoice
http://java.sun.com/blueprints/schemas/invoice.xsd">
<xsl:apply-templates/>
</bpi:Invoice>
</xsl:template>
<xsl:template match="bpi:InvoiceRef">
<bpi:InvoiceId><xsl:value-of select="text()"/>
</bpi:InvoiceId>
</xsl:template>
<xsl:template match="bpi:OPCPoId">
<bpi:OPCPoId><xsl:value-of select="text()"/></bpi:OPCPoId>
</xsl:template>
<xsl:template match="bpi:SupplierId">
<bpi:SupplierId><xsl:value-of select="text()"/>
</bpi:SupplierId>
</xsl:template>
<xsl:template match="bpi:Status">
<bpi:status><xsl:value-of select="text()"/></bpi:status>
</xsl:template>
</xsl:stylesheet>
Code Example 6.7 Style Sheet to Convert Supplier Invoice to Canonical Model
282 Data Integration Guidelines
The adventure builder application applies the style sheet when an invoice is
sent to a supplier. See “Reuse and Pool Parsers and Style Sheets” on page 188 for
more information about pooling style sheets.
Transition façades, which can apply to any object representation of data, are a
more general solution for transformations. You can use transition façades to hide
extra information or to provide simple mappings. To use a façade, you write a
Java class within which you do manual data transformation and mappings.
You should also consider using one of the many tools available for data trans-
formations. These tools simplify the data transformation task and make it easier to
maintain.
❐ When data is in an XML document, it is easier to write XSL style sheets that
do the required transformations.
❐ When you access data using EJB container-managed persistence, you can ei-
ther directly modify the container-managed persistent classes or write façades
to do the required transformations.
can filter the document to retrieve only this information. However, since it may
need to pass the entire invoice—all the data fields in the invoice—to the next step
in the workflow, the workflow manager must preserve the entire document. The
workflow manager can accomplish this using flexible mapping. (See “Flexible
Mapping” on page 148.)
On the other hand, you may want to apply data filtering before sending infor-
mation. For example, a credit card processing component of a workflow may need
to send credit information. The component should send only information required
for privacy protection and should use data filtering to remove information that
need not be passed to another application.
Filtering can be applied at the database level, too. Using filtering, you can
obtain a simplified view of the data tailored to a particular application. In addition,
using EJB container-managed persistence for data transformation makes it easier
to filter data. The container-managed persistence mapping tools let you select a
subset of the database schema, and this is analogous to filtering. If you are using
the JDBC RowSet approach, you need only select the columns for the data that
you care about.
You can also write façades that appropriately filter the data. In this case, the
client code accesses data only through these façades.
connector, but (with the help of other J2EE application server services) it may also
create a Web services layer.
Generally, there are two scenarios involving the integration of custom sys-
tems. In one case, two EIS systems need to interact with each other. The connector
approach works well with this type of scenario: You merely write Java classes
implementing the business logic for one EIS and use a connector to communicate
to the other EIS system. In the second scenario, you intend to have several appli-
cations use a custom EIS. For this case, it is better to plug the custom EIS into the
application server and expose the EIS’s reusable business logic through the appli-
cation server. You can expose the logic either by using enterprise beans with JMS
or by using a Web services approach. If the situation warrants it, you can use both
enterprise beans with JMS and a Web services approach together.
6.5.3 Metadata
Metadata is information that describes the characteristics of a data set. For an EIS
system, metadata describes the content, quality, and condition (among other charac-
teristics) of the EIS’s data.
EISs provide a range of access to this metadata. Some EISs provide program-
matic access to their metadata, while others provide the metadata information in
text form only, as a form of documentation. Sometimes, the metadata information
is available through database system support tools. For example, some databases
allow queries to learn its table names and schemas. Similarly, an EIS may give
you access to its various quality of service parameters.
Metadata is often relevant to integration. Metadata allows you to use tools to
discover properties of enterprise systems, and from this discovery to create appro-
priate, easy-to-use façades to the systems. By having access to metadata, tools can
generate more meaningful classes.
Web services are designed to support metadata. Web services rely on WSDL
files, which essentially provide metadata describing the services, the operations
offered by the services, parameters for these operations, and so forth. Since these
WSDL files are XML documents, they are accessible to tools and other programs.
(See “Web Services Description Language” on page 36.)
Using an integration layer helps make metadata more explicit. When metadata
is implicitly associated with EIS data, tools may have a difficult time discovering
the metadata. For example, a database table column may represent distances from
a certain point, and these distances are implicitly measured in miles. A tool that
accesses the data from this table column may not be able to determine whether the
distance is measured in miles or kilometers. By creating an integration layer, you
can make this information explicit. You can name the methods that access the data
in such a way as to indicate the associated metadata. For example, rather than
have a getDistance method, you can call the method getDistanceInMiles. For
Web services, the standard document formats that describe the service are
designed to make the metadata more explicit.
Another way to make metadata explicit and accessible, especially for medium
to large enterprises, is to store the metadata in a central location, such as a tradi-
tional LDAP directory. (LDAP, which stands for Lightweight Directory Access
Protocol, is an Internet protocol that programs can use to look up information
from a server.) You can make your EIS’s metadata available to others in several
ways. You can enable metadata support in your enterprise systems. The WSDL
file that accompanies a Web service already defines metadata for the service. You
286 Guidelines for Integration
may also provide specific methods that retrieve metadata related to quality of ser-
vices, parameter constraints, and so forth. Publishing a schema for a document
that a service accepts is another way to provide metadata.
When deciding what information to store in a directory, try to store data that is
useful to more than one application. Storing metadata in a directory also helps if
you need to analyze the impact of any changes to the application.
Also, consider implementing directory-based data sharing, since this enables
applications to operate collectively. Such data sharing reduces management costs
and improves an enterprise’s overall responsiveness to business change. If you use
this approach, be sure to set up authorization policies to control access to the data.
It is also important when using a directory service to locate authoritative or
reliable sources of the data. A major reason for not using a directory service is
outdated or suspect data. Users quickly learn that they cannot rely on the service
and hence stop using it. Keep in mind, however, that a single application or data-
base is rarely authoritative for all required data, and this may cause a data integra-
tion problem of its own.
the old service interface but re-implement the existing endpoint to use the new
implementation of the service. You may even be able to publish the new endpoint
under the same URL without breaking the existing clients. For example, if you are
just adding some additional ports to your WSDL, you should be able to update the
old WSDL with the new WSDL description and then existing clients should con-
tinue to work with no problems.
6.6 Conclusion
This chapter examined some of the key issues for enterprise application integration.
It began by illustrating typical integration problems encountered by enterprises, and
then described the various integration technologies available with the J2EE 1.4 plat-
form. These J2EE technologies are not limited to Web services only, though Web
services represent one valid integration approach most useful in certain situations. In
addition to Web services, the J2EE platform has technologies for integrating with
relational databases and other types of data stores, messaging technologies, and EIS
access technologies.
The chapter described the major J2EE application integration approaches—
including using Web services, enterprise beans and JMS, connectors, and data
Chapter 6 Enterprise Application Integration 289
access objects—and detailed the situations when it was most appropriate to use
these different approaches. It also showed how the various approaches could be
combined.
The chapter concluded with a set of guidelines for achieving data, application,
and business process integration. It also presented some guidelines for integrating
home-grown systems, along with how to leverage the capabilities of registries for
integration purposes.
Chapter 7 discusses the approaches for implementing secure Web services.