www.it-ebooks.info
Oracle SOA Suite 11g
Developer's Cookbook
Over 65 high-level recipes for extending your Oracle SOA
applications and enhancing your skills with expert tips and
tricks for developers
Antony Reynolds
Matt Wright
BIRMINGHAM - MUMBAI
www.it-ebooks.info
Oracle SOA Suite 11g Developer's Cookbook
Copyright © 2012 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or
transmitted in any form or by any means, without the prior written permission of the publisher,
except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the
information presented. However, the information contained in this book is sold without
warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers
and distributors will be held liable for any damages caused or alleged to be caused directly or
indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies
and products mentioned in this book by the appropriate use of capitals. However, Packt
Publishing cannot guarantee the accuracy of this information.
First published: December 2012
Production Reference: 1191212
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-84968-388-3
www.packtpub.com
Indexer
Hemangini Bari
Graphics
Aditi Gajjar
Production Coordinator
Nilesh R. Mohite
Cover Work
Nilesh R. Mohite
www.it-ebooks.info
About the Authors
Antony Reynolds has worked in the IT industry for more than 25 years, rst getting a job
to maintain yield calculations for a zinc smelter while still an undergraduate. After graduating
from the University of Bristol with a degree in Mathematics and Computer Science, he worked
rst for a software house, IPL in Bath, England, before joining the travel reservations system
Galileo as a development team lead. Galileo gave him the opportunity to work in Colorado and
Illinois where he developed a love for the Rockies and Chicago style deep pan pizza.
Since joining Oracle in 1998, he has worked in sales consulting and support. He currently works
as a Sales Consultant helping customers across North America realize the benets of standards
based integration and SOA. While at Oracle he has co-authored Oracle SOA Suite Developer's
Guide, Packt Publishing and Oracle SOA Suite 11g R1 Developer's Guide, Packt Publishing.
Antony lives in Colorado with his wife and four children who make sure that he is gainfully
employed playing games, watching movies, and acting as an auxiliary taxi service. He is a slow
but steady runner and can often be seen jogging up and down the trails in the shadow of the
Rocky Mountains.
I would like to thank my wife Rowan, and my four very patient children, who
have put up with my staying at home on family trips and working late nights
in my basement ofce as I completed this book. My managers Ed Lee and
Troy Hewitt were very supportive and many of my colleagues contributed
knowingly or unknowingly to the recipes.
and readability.
A book like this doesn't make it into print without a lot of work from the
publisher. I would like to thank the team at Packt Publishing for all their
support; especially Stephanie Moss, Leena Purkait, and Susmita Panda.
A special mention must go to John Deeb for his continual encouragement,
input, and above all support in ensuring that I found time to write the book;
I couldn't ask for a more supportive friend and business partner.
Finally, I would like to say a very, very special thank you to my wife Natasha
and my children Elliot and Kimberley, who have been incredibly patient and
supportive in allowing me to spend far too many evenings and weekends
stuck away in my ofce writing this book.
www.it-ebooks.info
Contributors
The creation of the content for this book has been very much a team effort, with many
contributions from the great team at Rubicon Red. In particular I would like to thank James
Goddard, Adrian Lewis, Brett Lomas, ShuXuan Nie, and Geoff Trench, each one of whom
contributed ideas and recipes to the book.
James Goddard is a software developer with 10 years of experience in IT, initially within
the telecommunication and utility industries in Melbourne, Australia. He specialised in system
integration design and development using Oracle Middleware before joining Rubicon Red as
a Consulting Architect in 2010. As a member of an energetic and innovative team of Oracle
experts, James was able to advise and contribute to SOA initiatives at a variety of organisations
around Australia.
He currently holds a position within Amazon Kindle, building highly scalable web services for
Amazon's digital product offerings in Seattle, WA.
Adrian Lewis is an SOA & Integration Solution Architect for Rubicon Red in Australia. He is
currently responsible for delivering a BPM and SOA solution for a Victorian state government
and Java development. He was awarded with the Java Developer of the year 2009 by Oracle
Magazine. In 2010, he won the EMEA Oracle Partner Community Award. He is the co-author
of the Oracle Service Bus 11g Development Cookbook, Packt Publishing, has contributed
to the Oracle SOA Handbook, Packt Publishing, is an international speaker at Oracle
OpenWorld & ODTUG, and has a popular blog called Java / Oracle SOA blog
(http://biemond.blogspot.com).
www.it-ebooks.info
www.PacktPub.com
Support les, eBooks, discount offers and more
You might want to visit www.PacktPub.com for support les and downloads related to your book.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub les
available? You can upgrade to the eBook version at www.PacktPub.com and as a print book
customer, you are entitled to a discount on the eBook copy. Get in touch with us at service@
packtpub.com for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a
range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
TM
http://PacktLib.PacktPub.com
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library.
Here, you can access, read and search across Packt's entire library of books.
Why Subscribe?
f Fully searchable across every book published by Packt
f Copy and paste, print and bookmark content
f On demand and accessible via web browser
Free Access for Packt account holders
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib
today and view nine entirely free books. Simply use your login credentials for immediate access.
Instant Updates on New Packt Books
Get notied! Find out when new books are published by following @PacktEnterprise on Twitter,
or the Packt Enterprise Facebook page.
Table of Contents
Chapter 4: Mapping Data 65
Introduction 65
Ignoring missing elements with XSLT 66
Ignoring missing elements with Assign 69
Creating target elements in Assign 71
Array processing with XSLT 73
Array processing with BPEL Assign 75
Overriding mapping of EJB data to XML 78
Ignoring a Java property 86
Creating a wrapper element for a Java collection or array 88
Handling an abstract class 90
Chapter 5: Composite Messaging Patterns 95
Introduction 95
Message aggregation within a composite 96
Using dynamic partner links with BPEL 2.0 103
Singleton composite 110
Scheduling services 115
Scheduling a service within a composite 119
Deleting a scheduled service within a composite 125
Chapter 6: OSB Messaging Patterns 127
Introduction 127
Dynamic binding using OSB 128
Splitting out messages using OSB 135
Dynamic Split-Join in OSB 140
Fault handling in dynamic Split-Join in OSB 150
Chapter 7: Integrating OSB with JSON 153
Introduction 153
Converting between XML and JSON 154
Invoking a JSON service from OSB 164
Chapter 12: Conguring OSB to Use Foreign JMS Queues 277
Introduction 277
Creating an OSB proxy service to consume JMS messages from OC4J 278
Creating an OSB business service to publish JMS messages to OC4J 282
Using WebLogic JMS Store-and-Forward for inter-domain messaging 289
Conguring OSB to consume JMS messages from JBoss
Application Server 5.1 296
Chapter 13: Monitoring and Management 303
Introduction 303
Capturing a composite completion status 305
Monitoring message throughput in real time 307
Deploy Monitor Express to BAM 311
Conguring BAM Adapter 314
Conguring a BPEL process to report the status to BAM Monitor Express 317
Index 321
www.it-ebooks.info
www.it-ebooks.info
Preface
Service Oriented Architecture (SOA) provides the architectural framework needed to
integrate diverse systems together and create new composite applications. Oracle SOA Suite
11gR1 provides the tools needed to turn an SOA architecture into a working solution. SOA
Suite provides the developer with several high level components such as:
f Oracle Service Bus (OSB), an enterprise strength service bus for full support of
service bus patterns including validation, enrichment, transformation, and routing
(the VETRO pattern)
f Service Component Architecture (SCA) that hosts a number of components
f Business Activity Monitoring (BAM) that provides real-time reporting on SOA
Suite activities
SCA components include:
f Mediator for light weight transformation and routing
Chapter 5, Composite Messaging Patterns, explores some of the more complex but relatively
common message interaction patterns used in a typical SOA deployment. It includes recipes
for implementing patterns around message aggregation, singletons, and the dynamic
scheduling of BPEL processes and services.
Chapter 6, OSB Messaging Patterns, explores some common message processing design
patterns for delegation of execution to downstream services and provides recipes for
implementing them using Oracle Service Bus. It includes recipes for dynamic binding to
services, splitting out messages, as well as dynamic Split-Joins.
Chapter 7, Integrating OSB with JSON, covers how we can use the Service Bus to integrate
with RESTful web services that exchange data using JavaScript Object Notation (JSON)
instead of XML. It also looks at how to expose OSB Services as RESTful JSON web services.
Chapter 8, Compressed File Adapter Patterns, explains how to use the le/FTP adapter
to compress/uncompress the contents of exchanged les. This is particularly common in
Business-to-Business scenarios, where network bandwidth is more of a constraint.
Chapter 9, Integrating Java with SOA Suite, explains different ways to integrate Java code into
SOA Suite. This is demonstrated through creating a custom XPath function for use in SCA and
OSB, as well as re-using EJBs and Spring Beans in SOA Suite. It also shows how to access the
SOA runtime environment from within a BPEL process.
www.it-ebooks.info
Preface
3
Chapter 10, Securing Composites and Calling Secure Web Services, shows the developer
how to restrict access to a composite by applying a security policy, as well as showing how
to create a new security policy. It also explains how to make a call to a security protected
service and how to manage security stores.
Chapter 11, Conguring the Identity Service, details how to congure the Oracle Platform
Security Services (OPSS) to use various LDAP providers for authentication and authorization
within the Oracle SOA Suite. It covers conguration for Active Directory, Oracle Internet
Directory, Sun iPlanet, and Oracle Virtual Directory.
Chapter 12, Conguring OSB to use Foreign JMS Queues, covers how to congure the Service
return total_price
When we wish to draw your attention to a particular part of a code block, the relevant lines
or items are set in bold:
Operation getTotalPrice( book_list ):
totalPrice := 0
for each order in book_list
loop
total_price := total_price +
Book.priceCheck(order.isbn ) * order.qty
end loop
return total_price
New terms and important words are shown in bold. Words that you see on the screen,
in menus or dialog boxes for example, appear in the text like this: "Open your proxy service
and select the Message Flow tab."
Warnings or important notes appear in a box like this.
Tips and tricks appear like this.
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about this book—
what you liked or may have disliked. Reader feedback is important for us to develop titles that
you really get the most out of.
To send us general feedback, simply send an e-mail to [email protected], and
mention the book title via the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or
contributing to a book, see our author guide on www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a number of things to help you
to get the most from your purchase.
www.it-ebooks.info
Preface
5
f Preparing the operating system
f Preparing the database
f Preparing the network
Introduction
An SOA Suite cluster can process more composite instances by spreading the load across
multiple machines, providing greater capacity. It also provides resiliency by allowing
composites to continue to execute on remaining machines in the cluster in the event of
a machine failing.
Using a cluster provides the following benets:
f Greater capacity
f Greater resiliency
Oracle provides a comprehensive guide to creating an SOA Suite cluster called the Enterprise
Deployment Guide (EDG). Rather than duplicating the guide, this chapter will provide recipes
that enhance the guide and elaborate on the steps required.
1
www.it-ebooks.info
Building an SOA Suite Cluster
8
Terms used
SOA Suite is normally deployed on a WebLogic application server and in this chapter we will
use WebLogic nomenclature to describe SOA Suite entities:
f Machine: A physical computer that hosts SOA Suite components
f Server: A WebLogic instance executing in a Java Virtual Machine
f Admin server: A WebLogic server that is used to manage the cluster
f Managed server: A WebLogic server that is dedicated to running applications
such as SOA Suite
Target solution
The following gure shows the target SOA Suite deployment architecture for a three-machine
SOA Suite cluster:
www.it-ebooks.info
run alongside the core SOA cluster. Hence, the SOA Suite
cluster has within it three WebLogic clusters, one of which,
the SOA cluster, has the core SOA Suite functionality.
In our three-machine cluster we have chosen to have an SOA Cluster with three managed
servers, a BAM cluster with two managed servers, and a WSM cluster with two managed
servers. We can adjust the number of managed servers in a cluster to accommodate different
numbers of physical machines. Note that in our example each machine hosts at least two
servers, but the machines may host more or fewer servers depending on their capacity (CPU,
memory, and network).
The Node Manager is responsible for monitoring the state of the managed servers and
restarting them in the event of failure, either on the original machine if possible, or in the
event of machine failure on another machine in the cluster.
Gathering conguration information
Before starting to build an SOA Suite cluster it is important to ensure that you have all the
required conguration information and the environment is prepared correctly. Time spent
doing this properly will save a lot of heartache and delay later.
Getting ready
Make sure you know how big a cluster you wish to build in terms of number of
managed servers.
How to do it
1. Create a drawing of the topology.
Before starting, make sure you understand the topology of the cluster you wish
to build and draw a picture of it either on a whiteboard or using a drawing tool
such as Visio.
www.it-ebooks.info