Oracle Service Bus 11g Development Cookbook - Guido Schmutz - E-Book

Oracle Service Bus 11g Development Cookbook E-Book

Guido Schmutz

0,0
47,99 €

oder
-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

Oracle Service Bus 11g is a scalable SOA integration platform that delivers an efficient, standards-based infrastructure for high-volume, mission critical SOA environments. It is designed to connect, mediate, and manage interactions between heterogeneous services, legacy applications, packaged solutions and multiple Enterprise Service Bus (ESB) instances across an enterprise-wide service network. Oracle Service Bus is a core component in the Oracle SOA Suite as a backbone for SOA messaging.
This practical cookbook shows you how to develop service and message-oriented (integration) solutions on the Oracle Service Bus 11g.
Packed with over 80 task-based and immediately reusable recipes, this book starts by showing you how to create a basic OSB service and work efficiently and effectively with OSB. The book then dives into topics such as messaging with JMS transport, using EJB and JEJB transport, HTTP transport and Poller transports, communicating with the database, communicating with SOA Suite and Reliable Message Processing amongst others. The last two chapters discuss how to achieve message and transport-level security on the OSB.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB

Veröffentlichungsjahr: 2012

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

Oracle Service Bus 11g Development Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
OSB Cookbook standard environment
Who this book is for
Recipes
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Creating a basic OSB service
Introduction
Creating a new OSB project
Getting ready
How to do it...
How it works...
There's more...
Defining a folder structure for the OSB project
Getting ready
How to do it...
How it works...
Importing an already existing project into Eclipse OEPE
Getting ready
How to do it...
How it works...
Creating a business service to call an external SOAP-based web service
Getting ready
How to do it...
How it works...
Generating a simple pass-through proxy service
Getting ready
How to do it...
How it works...
See also
Deploying the OSB configuration from Eclipse OEPE
Getting ready
How to do it...
How it works...
There's more...
Deploying to a remote server from Eclipse OEPE
Creating an OSB Configuration Jar and use the OSB console to deploy it
Testing the proxy service through the OSB console
Getting ready
How to do it...
How it works...
See also
Testing the proxy service through soapUI
Getting ready
How to do it...
How it works...
There's more...
Validate that the response is correct
Creating another request for the same operation
See also
Creating proxy service with a WSDL based interface
Getting ready
How to do it...
How it works...
Use the echo behaviour to implement a simple mock service
Using a routing action to statically route to another service
Getting ready
How to do it...
How it works...
See also
Adding an operational branch to support the different WSDL operations of the proxy service
Getting ready
How to do it...
How it works...
There's more...
Do I have to implement a branch for each operation?
How to handle operations which are not yet supported?
See also
Using an XQuery transformation to map between the different data models of the services
Getting ready
How to do it...
How it works...
2. Working Efficiently with OSB Artifacts in Eclipse OEPE
Introduction
Setting up an OSB project to work with JCA adapters
Getting ready
How to do it...
How it works...
See also
Using context menu to add nodes and actions to message flow
Getting ready
How to do it...
How it works...
Moving nodes/actions in Eclipse OEPE by drag-and-drop
Getting ready
How to do it...
How it works...
Copying nodes/actions from one place to another
Getting ready
How to do it...
How it works...
Moving artifacts inside the same OSB project
Getting ready
How to do it...
How it works...
Copying artifacts from one project into another
Getting ready
How to do it...
How it works...
There's more...
Debugging services through Eclipse OEPE
Getting ready
How to do it...
How it works...
3. Messaging with JMS Transport
Introduction
Sending a message to a JMS queue/topic
Getting ready
How to do it...
How it works...
There's more...
Advanced settings on JMS Transport
Sending to a JMS topic
See also
Changing JMS Transport message headers and properties at runtime
Getting ready
How to do it...
How it works...
Consuming messages from a JMS queue
Getting ready
How to do it...
How it works...
Consuming messages from a topic with non-durable/durable subscription
Getting ready
How to do it...
How it works...
There's more...
Consuming messages from a JMS queue/topic selectively
Getting ready
How to do it...
How it works...
There's more...
Using user-defined properties in a message selector
Using compound expressions in a message selector
See also
Accessing JMS Transport headers and properties in message flow
Getting ready
How to do it...
How it works...
There's more...
Accessing user-defined JMS properties
Using request-response messaging with JMS
Getting ready
How to do it...
How it works...
There's more...
Using QBrowser Admin GUI for accessing JMS queues/topics
Getting ready
How to do it...
How it works...
See also
Testing JMS with soapUI
Getting ready
How to do it...
How it works...
There's more...
4. Using EJB and JEJB transport
Introduction
Exposing an EJB session bean as a service on the OSB using the EJB transport
Getting ready
How to do it...
How it works...
There's more...
Locate an EJB in the JNDI tree
What if the EJB method returns a list of objects?
Using JNDI Provider to invoke an EJB session bean on a remote WebLogic domain
Getting ready
How to do it...
How it works...
Using converter class with EJB transport to help converting data types
Getting ready
How to do it...
How it works...
Exposing an EJB session bean as an EJB on the OSB using the JEJB transport
Getting ready
How to do it...
How it works...
Manipulating the response of the JEJB transport by a Java Callout action
Getting ready
How to do it...
How it works...
There's more...
5. Using HTTP Transport
Introduction
Using HTTP transport to implement messaging over HTTP
How to do it...
How it works...
There's more...
Exposing a RESTful service on the OSB
Getting ready
How to do it...
How it works...
There's more...
Consuming a RESTful service from the OSB
Getting ready
How to do it...
How it works...
Creating a generic RESTful gateway on the OSB
Getting ready
How to do it...
How it works...
Implementing a WebSockets transport for server-side push
Getting ready
How to do it...
How it works...
There's more...
6. Using File and Email Transports
Introduction
Using the File or FTP transport to trigger a proxy service upon arrival of a new file
Getting ready
How to do it...
How it works...
There's more...
File and FTP transports versus JCA adapters
Selectively processing files
Processing binary files
See also
Using the File JCA adapter to read a file within the message flow
Getting ready
How to do it...
How it works...
There's more...
Setting the filename and folder name dynamically at runtime
Reading file resources through a XQuery script
See also
Using the File Transport to write to a file
Getting ready
How to do it...
How it works...
There's more...
Specifying a filename at runtime
Writing a file to a remote folder through FTP
Using Email Transport to receive e-mail
Getting ready
How to do it...
How it works...
There's more...
Using Email Transport to send e-mail
Getting ready
How to do it...
How it works...
There's more...
7. Communicating with the Database
Introduction
Using DB adapter to read from a database table
Getting ready
How to do it...
How it works...
Using DB adapter to execute a custom SQL statement against the database
Getting ready
How to do it...
How it works...
There's more...
Using the DB adapter to update a database table
Getting ready
How to do it...
How it works...
There's more...
A Note on the Detect Omissions Flag
The side effect of the Get Active UnitOfWork flag
Using DB adapter to poll for changes on a database table
Getting ready
How to do it...
How it works...
There's more...
What kind of database changes may be detected
What are the possibilities of marking processed rows
How to modify the query when polling the database
Options regarding runtime behavior
Using the AQ adapter to consume messages from the database
Getting ready
How to do it...
How it works...
There's more...
See also
Using the AQ adapter to send messages to the database
Getting ready
How to do it...
How it works...
There's more...
8. Communicating with SOA Suite
Introduction
Invoking a SCA composite synchronously from an OSB service
Getting ready
How to do it...
How it works...
There's more...
See also
Invoking a SCA composite asynchronously from an OSB service
Getting ready
How to do it...
How it works...
Invoking an OSB service from SCA composite synchronously
Getting ready
How to do it...
How it works...
Invoking an OSB service from SCA composite asynchronously
Getting ready
How to do it...
How it works...
9. Communication, Flow Control, and Message Processing
Introduction
Using Service Callout action to invoke a service
Getting ready
How to do it...
How it works...
There's more...
Using the Publish action to asynchronously invoke a service
Getting ready
How to do it...
How it works...
See also
Using the Java Callout action to invoke Java code
Getting ready
How to do it...
How it works...
There's more...
Using the Java Callout action with XMLBeans
Getting ready
How to do it...
How it works...
There's more...
Using custom XPath functions
Getting ready
How to do it...
How it works...
There's more...
Using the For Each action to process a collection
Getting ready
How to do it...
How it works...
See also
Using dynamic Split-Join to perform work in parallel
Getting ready
How to do it...
How it works...
See also
Using the Validate action to perform message validation
Getting ready
How to do it...
How it works...
Enabling/disabling a Validate action dynamically
Getting ready
How to do it...
How it works...
Creating private proxy service
Getting ready
How to do it...
How it works...
10. Reliable Communication with the OSB
Introduction
Configuring Retry handling in JMS
Getting ready
How to do it...
How it works...
There's more...
Enabling JMS message persistence
Getting ready
How to do it...
How it works...
There's more...
Working with global transactions and quality of service
Getting ready
How to do it...
How it works...
Using WS-Reliable Messaging (WS-RM) with WS transport
Getting ready
How to do it...
How it works...
There's more...
SOAP over JMS
Getting ready
How to do it...
How it works...
11. Handling Message-level Security Requirements
Introduction
Preparing OSB server to work with OWSM
Getting ready
How to do it...
How it works...
Configuring OSB server for OWSM
How to do it...
How it works...
There's more...
Securing a proxy service by Username Token authentication
Getting ready
How to do it...
How it works...
There's more...
Securing a proxy service by protecting the message
Getting ready
How to do it...
How it works...
There's more...
Securing a proxy service by using Username Token authentication and protecting the message
Getting ready
How to do it...
How it works...
Securing a proxy service by using certificate authentication and protecting the message
Getting ready
How to do it...
How it works...
See also
Securing a proxy service with authorization through Message Access Control
Getting ready
How to do it...
How it works...
There's more...
Using users, groups, and roles instead of individual users
Making a resource available only during working hours
Using JDeveloper to test a secured service
Getting ready
How to do it...
How it works...
There's more...
Implementing a JDeveloper test client for service with Username Token authentication
Implementing a JDeveloper test client for service with message protection
Calling a secured service from OSB
Getting ready
How to do it...
How it works...
There's more...
Making the business service work with the default credential
Keys used for signing and encrypting if a message protection client policy is configured on the business service
12. Handling Transport-level Security Requirements
Introduction
Using service accounts with OSB
Getting ready
How to do it...
How it works...
There's more...
Static service accounts
Mapping service accounts
Service accounts from XQuery
Configuring WebLogic network connection filters
Getting ready
How to do it...
How it works...
There's more...
Preparing OSB server to work with SSL
Getting ready
How to do it...
How it works...
Configuring a proxy service to use HTTPS security
Getting ready
How to do it...
How it works...
Index

Oracle Service Bus 11g Development Cookbook

Oracle Service Bus 11g Development 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: January 2012

Production Reference: 1180112

Published by Packt Publishing Ltd.

32 Lincoln Road

Olton

Birmingham, B27 6PA, UK.

ISBN 978-1-84968-444-6

www.packtpub.com

Cover Image by David Gimenez (<[email protected]>)

Credits

Authors

Guido Schmutz

Edwin Biemond

Eric Elzinga

Mischa Kölliker

Jan van Zoggel

Reviewers

Jelle de Bruin

Matthias Furrer

Matt Wright

Peter van Nes

Acquisition Editor

Kerry George

Lead Technical Editor

Meeta Rajani

Technical Editors

Apoorva Bolar

Arun Nadar

Naheed Shaikh

Project Coordinator

Kushal Bhardwaj

Proofreaders

Matthew Humphries

Cecere Mario

Indexer

Rekha Nair

Graphics

Manu Joseph

Conidon Miranda

Production Coordinator

Aparna Bhagat

Cover Work

Aparna Bhagat

About the Authors

Guido Schmutz is an Oracle ACE director for Fusion Middleware and SOA and works for the Swiss Oracle Platinum Partner Trivadis—an independent consulting firm specializing in Oracle and Microsoft product stack. He has more than 25 years of technology experience, ranging from mainframes, integration, and SOA technologies in financial services, government, and logistics environments. At Trivadis he is responsible for SOA BPM and Application Integration solutions and leads the Trivadis Architecture Board. He has long-time experience as a developer, coach, trainer, and architect in the area of building complex Java EE and SOA-based solutions. Currently, he is focusing on SOA and application integration projects using the Oracle SOA Suite. Guido is a regular speaker at international conferences such as Oracle Open World, ODTUG, SOA Symposium, UKOUG conference, and DOAG. He is also co-author of the books Service-Oriented Architecture: An Integration Blueprint, Spring 2.0 im Einsatz, Architecture Blueprints, and Integration Architecture Blueprints. Guido runs his own blog at http://guidoschmutz.wordpress.com.

First of all I would like to thank all my co-authors for their hard work that lead to this book. I enjoyed working with you guys a lot!

Thanks a lot to the reviewers Matthias Furrer, Jelle de Bruin, Matt Wright and Peter van Nes for their work. Your feedback was very valuable and helpful!

A book like this one is not possible without a lot of work from the publisher. In the name of my fellow co-authors, I would like to thank the team at Packt Publishing for their help and support, especially Kerry George, Kushal Bhardwaj, Meeta Rajani, and Arun Nadar. It has been a long process with a lot of work, but we are very happy with the result we have achieved!

Thanks to my employer Trivadis for the support and for giving me the opportunity to write this book.

Last but not least I would like to thank my wonderful wife Renata and my family for their love and all the support. Without their help and understanding, this book would not have been possible.

Hope you like this book as much as I enjoyed writing it!

Edwin Biemond is an Oracle ACE and solution architect at Amis, specializing in messaging with Oracle SOA Suite and Oracle Service Bus. He is an expert in ADF development, WebLogic administration, high availability, and security. His Oracle career began in 1997 when he was developing an ERP CRM system with Oracle tools. Since 2001, Edwin changed his focus to integration, security, and Java development. Edwin was awarded with the Java Developer of the Year 2009 award by Oracle Magazine and in 2010 won the EMEA Oracle Partner community award, he contributed some content to the SOA Handbook of Lucas Jellema. He is also an international speaker at Oracle OpenWorld & ODTUG and has a popular blog called Java/Oracle SOA blog at—http://biemond.blogspot.com.

Eric Elzinga is an Oracle ACE for Fusion Middleware and SOA. He has over 10 years of experience in IT. His Oracle career started around 2001 as an Oracle database programmer and building enterprise portal applications. Lately, he is focusing on SOA and integration solutions based on the Oracle SOA Suite, Oracle Service Bus, and open source frameworks. He is also experienced in designing and maintaining middleware solutions, messaging, and creating business solutions using agile software development with Scrum. He is the owner of Xenta Consultancy. Eric is an active contributor to the Oracle Community/Forums and blogs on his website at http://blog.xenta.nl.

A thanks goes out to all the co-authors for their months of hard work. I really enjoyed the time!

I want to thank my mom for the never-ending support and believing in me. My dad, RIP, I hope you’re proud of me.

Mischa Kölliker is a principal consultant at the Oracle consultancy company Trivadis. He has been working for more than 15 years in the area of integration solutions with technologies such as C++, Java EE, and Oracle Service Bus. At Trivadis he works as a solution architect, developer and trainer in SOA, integration, and Java EE projects. In his current assignments, he works on OSB-based integration solutions for Swiss railway and touristic organizations as well as on a Java EE project for a Swiss bank. His avocation is HTML5 and all related technologies. Mischa is a co-author of other books, including the Architecture Blueprints and the Business Communication Architecture Blueprint.

Jan van Zoggel is a principal Oracle Fusion Middleware consultant and works for the Dutch Oracle Gold Partner Rubix. He is experienced with process and system integration based upon the products Oracle Service Bus, Oracle Weblogic, and the Oracle SOA Suite. His IT career began in 2000 and in 2004, he changed his focus to message brokers, Enterprise Application Integration (EAI) and Business-to-Business (B2B) which later shifted towards Service Oriented Architecture (SOA) based upon the Oracle (BEA) and Tibco software suites. He has worked in different roles as a middleware operational support, process and service developer, solution architect, and as a trainer. His main area of interest is middleware architecture, high availability, reliable messaging, security, and cloud technology. Jan runs his own blog at http://jvzoggel.wordpress.com

I would like to thank all the other co-authors for their hard work, and especially Guido who went beyond the call of duty to finish this project successful. This was my first experience as a co-writer and I really enjoyed it. But especially I would like to thank my family and loved ones for their support, understanding, and in particular their ever-lasting patience.

About the Reviewers

Jelle de Bruin is a very experienced IT consultant. Having started his career on mainframe systems, he moved to the Java world at the end of the last century. In 2007, he joined the professional services department of BEA Systems Netherlands. During his time at BEA and later at Oracle, he worked extensively in customer facing assignments with the AquaLogic Service Bus or the Oracle Service Bus as it is now called. Although he has extensive knowledge and experience with other Oracle Fusion Middleware products, the Service Bus has become his specialty.

Now, he is working as an independent consultant on a variety of projects, ranging from enterprise architecture to working with Oracle Fusion Middleware products. In his role as an independent consultant, he is still asked by Oracle to help them out on occasions.

Matthias Furrer has been working in different roles for more than 20 years in IT. Throughout his career he worked as an application developer, consultant, and architect in many complex integration projects. Now, he is working as a senior consultant for Trivadis—a leading solution provider for infrastructure engineering, application development, and business intelligence operating in Switzerland, Germany, and Austria.

Peter van Nes is an Oracle Fusion Middleware consultant and works within a partnership of the Oracle SOA Specialized Gold Partner, The Future Group. In 1991, he started his career as a Systems Management consultant and changed his focus in 2005 to Oracle products and Java. In his current assignment, he mainly develops BPEL processes and OWSM security pipelines for an international financial services provider, and, as a senior developer, he is actively involved in the migration to 11g SOA Suite, using BPEL and OSB. In addition, Peter contributes to the Oracle community by blogging on his website, http://www.petervannes.nl.

www.PacktPub.com

Support files, eBooks, discount offers and more

You might want to visit www.PacktPub.com for support files and downloads related to your book.

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files 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 <[email protected]> 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.

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?

Fully searchable across every book published by PacktCopy and paste, print, and bookmark contentOn 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.

Preface

The Oracle Service Bus 11g (OSB) is a scalable SOA integration platform that delivers an efficient, standards-based infrastructure for high-volume, mission critical SOA environments. It is designed to connect, mediate, and manage interactions between heterogeneous services, legacy applications, packaged applications, and multiple Enterprise Service Bus (ESB) implementations (such as other OSB instances, Microsoft BizTalk, IBM WebsSphere ESB, SAP-XI, ...and so on) across an enterprise-wide service network. Oracle Service Bus is a core component of the Oracle SOA Suite.

This practical cookbook shows you how to develop service- and message-oriented (integration) solutions on the Oracle Service Bus 11g.

This practical cookbook shows you how to develop service- and message-oriented (integration) solutions on the Oracle Service Bus 11g.The book contains more than 80 practical recipes, showing how to efficiently develop on the Oracle Service Bus. In addition to its cookbook style, which ensures the solutions are presented in a clear step-by-step manner, the explanations go into great detail, which makes it good learning material for everyone who has experience with the OSB and wants to improve. Most of the recipes are designed in such a way that each one is presented as a separate, standalone entity and reading of prior recipes is not required. The finished solution of each recipe is also made available electronically.

What this book covers

Chapter 1, Creating a Basic OSB Service, teaches how to structure a project through the Eclipse OSB plugin, what conventions and best practices to apply, and how to use proxy and business service to create a simple message flow on the Oracle Service Bus. We will also learn how to test an OSB service through the Service Bus console and through soapUI.

Chapter 2, Working Efficiently with OSB Artifacts in Eclipse OEPE, presents some tips and tricks for simplifying working in Eclipse with the OSB Plugin. We will also learn how to use the visual debugger for step-by-step debugging of OSB services.

Chapter 3, Messaging with JMS Transport, shows how to use the JMS transport for sending and receiving message through JMS queues and topics. Additionally this chapter also shows how to use other tools such as soapUI and QBrowser to support the testing of JMS applications.

Chapter 4, Using EJB and JEJB Transport, teaches us how to use the EJB and JEJB transport for integrating and exposing EJB session beans.

Chapter 5, Using HTTP Transport, presents how to use the HTTP transport for implementing RESTful web services and how to implement a custom transport which uses WebSockets to implement server-side push messaging.

Chapter 6, Using File and Email Transports, shows how to use the File and FTP transport for reading and writing files and how to use the Email transport for receiving and sending emails from an OSB service.

Chapter 7, Communicating with the Database, shows with different recipes how the DB adapter can be used to integrate an OSB service with a relational database, and how the AQ adapter can be used to implement messaging between OSB and an Oracle database.

Chapter 8, Communicating with SOA Suite, teaches us how to use the SOA direct transport to natively communicate between SOA Suite service components and OSB services.

Chapter 9, Communication, Flow Control, and Message Processing, presents how to use different actions from the Communication, Flow Control, and Message Processing section of the OSB Design Palette.

Chapter 10, Reliable Communication with the OSB, contains recipes that will show how to use the various features of the OSB and WebLogic JMS to implement reliable message processing.

Chapter 11, Handling Message-level Security Requirements, shows different options for securing OSB services on the message-level to guarantee end-to-end security between an initial sender and an ultimate receiver.

Chapter 12, Handling Transport-level Security Requirements, contains recipes for securing OSB services on the transport protocol level.

What you need for this book

To develop and test the recipes in this book, an Oracle Service Bus 11g Patch Set 3 (11.1.1.4 or higher) and an Oracle Database11g (XE or Enterprise edition) needs to be installed on the system. For Chapter 8, a full installation of Oracle SOA Suite 11g (11.1.1.4 or higher) including Enterprise Manager needs to be installed as well.

An installation of JDeveloper with the SOA Suite extension (11.1.1.4 or higher) is necessary for Chapter 2, Chapter 3, Chapter 7 and Chapter 8.

To use the web-based consoles, either Internet Explorer or Firefox is necessary.

We have developed all the recipes on the so-called "developers" installation of Oracle Service Bus 11g and Oracle SOA Suite 11g. This means that all the software is running on one single Admin Server and there are no additional Managed Servers needed, limiting the resources needed on the system. When we started writing the book, Oracle Service Bus Patch Set 3 (11.1.1.4) was the actual release and we have implemented all the recipes using this version. Keep that in mind when interpreting the screenshots, although most of the time this is transparent and not relevant. A place where it is certainly relevant is when entering the URI of the OSB server (that is, to open the Service Bus console). In our installation, having only an Admin Server, the port we use throughout the book is always 7001. Make sure to change that in case of a different installation.

For testing some of the recipes, the latest version of soapUI needs to be available. In Chapter 3, QBrowser and HermesJMS will be used to test JMS queues and topics.

For Chapter 6, an FTP server needs to be available. The corresponding recipe guides you through the installation of CoreFTP Server. Also in Chapter 6, an e-mail server and e-mail client is needed. The corresponding recipe describes the necessary steps for installing Apache James as the mail server and Mozilla Thunderbird as the e-mail client.

To guide you through the installation of the various components, we have written an extra document only available electronically. To download the installation guide, go to the Packt homepage for the OSB cookbook and download the ZIP file containing the code for the book. Included in the ZIP file is a PDF document named OsbCookbookInstallationGuide.pdf.

OSB Cookbook standard environment

The OSB Cookbook standard environment is a set of artifacts, representing the environment that most of the recipes make use of.

Part of the environment is a database schema to be installed in an Oracle database, containing a few tables and AQ objects. The database schema can be installed by running the script setup\database\install.cmd.

Another part of the environment is installed on the WebLogic server. This includes artifacts stored in the JNDI tree, such as DataSource or Connection Factories as well as the necessary JMS objects for Chapter 3. These artifacts are installed through a WLST script, which is called from an ANT script. Install it by running the script setup\wlst\install.cmd.

These two scripts are part of the ZIP file for this book, downloadable from the Packt website.

Who this book is for

If you are an intermediate SOA developer who is using Oracle Service Bus to develop service and message-orientated applications, then this book is for you. The book assumes that you have a working knowledge of fundamental SOA concepts and Oracle Service Bus.

Recipes

To keep the initial preparation of each recipe short, a lot of the recipes start from a base setup, which in most cases is an already existing OSB project including some initial artifacts and some base configuration. All the base setup artifacts are available in the chapter-<N>\getting-ready\<recipe-name> folder available in the ZIP file for this book. Each recipe refers to the corresponding folder in the Getting Ready section.

It will often be necessary to import an existing OSB project into Eclipse OEPE (for example, the OSB Plugin). The recipe Importing an already existing project into Eclipse OEPE in Chapter 1, Creating a Basic OSB Service, explains how to do that.

The solution of each recipe is available electronically in the folder chapter-<N>\solution\<recipe-name>, which is also part of the ZIP file for this book.

For most of the recipes we have created a simple, schematic diagram, representing the solution and the participating artifacts. The following image shows such a diagram taken from Chapter 1, Creating a Basic OSB Service.

The following diagram shows a legend with the different symbols and their meanings used throughout this book.

We strongly believe in the adage "a picture is worth a thousand words" and hope that these schematic diagrams will help the reader to quickly understand the setup of each recipe.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "Open <HERMES_HOME>\bin\hermes.bat and add the following JAVA_HOME and PATH variable right at the beginning".

A block of code is set as follows:

<configuration> <location> <directory>c:\work\files\in</directory> <filename>OtherProperties.xml</filename> </location> </configuration>

Any command-line input or output is written as follows:

keytool -exportcert -alias clientKey -storepass welcome -keystore c:\client_2.jks -file c:\client_2.cer

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: "Navigate to the Configuration tab, and select the Outbound Connection Pools tab".

Note

Warnings or important notes appear in a box like this.

Tip

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 through 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.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website, or added to any list of existing errata, under the Errata section of that title.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at <[email protected]> with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at <[email protected]> if you are having a problem with any aspect of the book, and we will do our best to address it.

Chapter 1. Creating a basic OSB service

In this chapter, we will cover the following topics:

Creating a new OSB projectDefining a folder structure for the OSB projectImporting an already existing project into Eclipse OEPECreating a business service to call an external SOAP-based web serviceGenerating a pass-through proxy serviceDeploying the OSB configuration from Eclipse OEPETesting the proxy service through the OSB consoleTesting the proxy service through soapUICreating a proxy service with a WSDL-based interfaceUsing a routing action to statically route to another serviceUsing an operational branch to implement multiple WSDL operations in a proxy serviceUsing an XQuery transformation to map between the different data models of the services

Introduction

In this chapter, we will cover some basic recipes to get the reader started working with the Oracle Service Bus (OSB). We will first develop the simplest possible service on the OSB with only one proxy service and then recipe by recipe add some more functionality to that service. In contrast to the other chapters, the recipes in this chapter are dependent on each other, and all the recipes of this chapter should therefore, be done in order. On the other hand, each single recipe can also be applied standalone by importing the 'getting-ready' project referenced in the Getting, Ready section of each recipe.

In some of the recipes, we will also define the best practices and development conventions that we will use for this book, however, they are also applicable in any other project. We teach how to best structure a project using Eclipse OEPE (with the OSB plugin installed).

In this recipe, we will implement a mediation service in the OSB, which consumes a web service from an external CRM system.

Creating a new OSB project

In order to develop on the Oracle Service Bus, an OSB project needs to be available. This recipe will show how such an empty OSB project can be created. Such a project can either be created through the web-based OSB console or through the more developer-friendly Eclipse OEPE. Eclipse OEPE is an Eclipse IDE with Oracle Enterprise Plugin for Eclipse (OEPE) and the OSB plugin installed.

Getting ready

Make sure that you have access to a working Eclipse OEPE.

How to do it...

In Eclipse OEPE, perform the following steps:

From the File menu, pick New | Other.Type Oracle Service Bus in the Wizards tree list:Choose Oracle Service Bus Project from the list and click on the Next button.Enter basic-osb-service into the Project name fild: Click on the New button to create an OSB Configuration (if there is not yet one).Enter osb-cookbook-configuration into the Configuration name field.Click on the Finish button to create the empty OSB project.Click on Yes to confirm that Eclipse OEPE will switch to the Oracle Service Bus perspective.

We have now created an empty OSB project inside our Eclipse worksace.

How it works...

An OSB project created through Eclipse OEPE is just a folder created below the location of the workspace. Visually, Eclipse OEPE shows it wrapped inside the osb-cookbook-configuration OSB configuration, but they are really both on the same level, just a subfolder of the workspace folder.

The project contains a .project file and a .settings folder like any Eclipse project. These files hold the necessary meta information about the project. An OSB project has the special Oracle Service Bus facet assigned.

This empty project can now be used to create the different OSB artifacts necessary for an OSB service. They can either be placed directly inside the project folder or a subfolder structure can be created in order to organize the OSB project. How to create a folder structure will be shown in the next recipe, Defining a folder structure for the OSB project.

There's more...

A new OSB project can also be created through the OSB console. The main difference to the approach shown before is that, through the OSB console we directly work on a running Oracle Service Bus instance. When using Eclipse OEPE, the project is stored in the Eclipse workspace and needs to be later deployed to an OSB instance. See the next recipe, to learn how to create a folder structure for holding the different OSB artifacts.

Defining a folder structure for the OSB project

After creating the empty OSB project, we will prepare a folder structure to be used to organize the project. OSB allows you to use folders to build-up a project structure which helps to better find the various artifacts inside the OSB project.

Getting ready

Make sure that the empty OSB project—basic-osb-service from the previous recipe is available in the Eclipse OEPE. Also make sure that the Oracle Service Bus perspective is active in Eclipse. The active perspective can be identified in the upper-right corner of the Eclips window:

To switch to another perspective, click on the Window menu, select Open Perspective | Other and then select the Oracle Service Bus in the list of perspectives.

If after a while a certain perspective gets messed up and some windows or views are missing, then the perspective can always be reset to the factory settings by clicking on the menu Window | Reset Perspective and then confirming the dialog with the OK button.

How to do it...

In Eclipse OEPE, perform the following steps:

Right click on the basic-osb-service project and select New | Folder.Enter proxy in the Folder name field:Repeat these two steps for the folders business, wsdl, xsd, and transformation. These are the most common folders and they altogether form the basic OSB project structure used in this book.

How it works...

Folders help to structure the projects and by that organize the different artifacts that we will create later. The folder structure will also be visible after the deployment of a project in the OSB console. So at runtime, if someone (that is, the administrator) needs to navigate to a certain artifact through the console, a clever folder structure can make life much easier.

The meaning of the folder structure that we will use in this book is listed in the following table:

Folder name

Used for organizing

business

business services artifacts

proxy

proxy services artifacts

wsdl

SOAP-based web service interfaces

xsd

the XML schema files

transformation

Artifacts for doing data model transformations, such as XQuery and XSLT scripts

In some specific recipes, we will add some additional folders. The ones shown in this recipe just represent the most commonly used ones.

Importing an already existing project into Eclipse OEPE

Working with Eclipse OEPE, there is often a need to open an already existing OSB project, which is (no longer) in your Eclipse workspace. This recipe will show how to import an existing project. It should be used in all future recipes, when the Getting, ready section asks for importing an existing OSB project as the base for following the recipe.

Getting ready

Make sure that you have access to a working Eclipse OEPE.

How to do it...

In Eclipse OEPE, perform the following steps:

From the File menu select Import.Type Existing in the Select an import source tree list.Select Existing Projects into Workspace from the tree and click Next.Click on the Browse button to specify the root directory from where to import the project.Navigate to the \chapter-1\getting-ready folder and click on the OK button.Select the already-existing-osb-project from the list of projects to import and select the Copy projects into workspace option:Click on the Finish button.

The project is now imported in Eclipse OEPE but will be placed outside of the OSB Configuration and therefore, will have an error marker.

To move it into the OSB Configuration, just drag the imported already-existing-osb-project in the Project Explorer into the osb-cookbook-configuration project. Now the project is ready to be used.

How it works...

To import the OSB project into Eclipse OEPE, we just used the standard import functionality of Eclipse. In order for that to work, the project needs to have the .project, which is automatically created when using Eclipse OEPE to create an OSB project.

The project has to be moved into the OSB configuration in order to be able to work with it, that is, deploy it to the OSB server. Dragging the project into the OSB configuration is only reflected inside Eclipse, it does not change the location of the files on the disk.

Creating a business service to call an external SOAP-based web service

With the basic folder structure of the OSB project in place, we are ready to create our first OSB service. We will start with the business service Customer Service which will act as a wrapper of the external service. Business services in OSB are required definitions to exchange messages with enterprise information systems—such as databases and queues or other web services. The external service is a web service offered by a fictive CRM system. The business service will allow the definition of all sorts of properties for controlling how the external service is invoked:

Getting ready

Make sure that the external web service we want to invoke is started by running the script \chapter-1\getting-ready\misc\customer-external-webservice\start-service.cmd. This service is implemented using soapUI's capabilities for creating mock services.

Verify that the service is running and available by asking it for its WSDL definition. Enter the following URI in a browser window: http://localhost:8088/mockCustomerServiceSOAP?WSDL:

How to do it...

In Eclipse OEPE, perform the following steps:

In the project tree, right-click on the business folder and select New | Business Service.Enter CustomerService into the File name field, check a second time that the business folder is selected, and click on the Finish button:A new business service artifact is created in the business folder and the editor for the business service opens automatically.Navigate to the General tab, if it does not already have the focus, and select the WSDL Web Service radio button.Click on the Browse button and a pop up window will show up, where the WSDL resource of the external service to be wrapped, can be selected.Click on the Consume button.A second pop-up window will show up where the WSDL resource can be specified:Select URI in the Service Resource drop-down listbox.In the URI field, enter the URL of the WSDL resource to consume. The external service provides its WSDL through the following URL: http://localhost:8088/mockCustomerServiceSOAP?WSDL.Click on the OK button and Eclipse will consume the WSDL from this URL.Select the CustomerServiceSOAP port on the next window.Click on the OK button.Select Yes on the pop-up message window to confirm that the transport configuration settings will be overwritten by the information from the selected WSDL.Save the OSB project by selecting File | Save.In the Project Explorer, right-click on the imported WSDL file mockCustomerServiceSOAP.wsdl and select Rename. Enter CustomerService.wsdl into the New name field of the pop-up window and confirm.In the Project Explorer, drag the CustomerService.wsdl file into the wsdl folder and drop it there. All the references to the WSDL file are automatically adapted by Eclipse OEPE.Navigate to the Transport tab and check that the Endpoint URI has been replaced with the service endpoint setting from the WSDL that we consumed:Save the artifact by selecting File | Save or by clicking on the Save toolbar button.

How it works...

The business service acts as a wrapper of our external service. Once created, we will no longer have to use the WSDL to refer to the external service, but can use the business service. This forms an additional abstraction layer, which will become handy later in some of the more advanced recipes to enable functionality in the OSB, which is applied before the real endpoint is invoked, such as SLA monitoring, service throttling, service pooling, and others. Sentence is too long, runs on too long. Would be better split into two sentences.

Generating a simple pass-through proxy service

After we have created the business service wrapping the external web service, we can now create the proxy service. The proxy service will allow a consumer to call our service on the OSB. If the OSB needs to support the same web service interface as the backend service does, then the quickest and easiest way is to create a pass-through service:

Getting ready

This recipe continues with the result of the previous recipe. If necessary, the basic-osb-service project at that stage can be imported from here: \chapter-1\getting-ready\business-service-created.

How to do it...

In Eclipse OEPE, perform the following steps:

In the project tree, right-click on the CustomerService.biz artifact and select Oracle Service Bus | Generate Proxy Service.Enter CustomerService in the File name field and select the proxy folder for the location of the new proxy service.Click on the Finish button.Click on the Transport tab and check the value of the Endpoint URI field. It should be /basic-osb-service/proxy/CustomerService.Navigate to the Message Flow tab and have a look at the message flow, which has been generated by Eclipse OEPE. A Route node with a nested Routing action has been created with its Invoking properties set to Use inbound operation for outbound:

How it works...

Applying this recipe created the simplest possible proxy service. The proxy service offers the same SOAP-based web service interface as the business service/external service, so it's basically just doing a pass-through of the request and response message.

This can be handy if we want to use the OSB for adding an additional abstraction layer to apply service virtualization. If all the service consumers no longer access the external services directly, but only through the OSB proxy-service, a lot of the features of OSB can be used transparently by a service consumer, such as SLA monitoring and alerting, service pooling and throttling, or message validation. This directly supports the main goal of service virtualization—adding operational agility.

By setting the Invoking property to Use inbound operation for outbound, we make sure that the whole WSDL with all its operations is handled by one single Routing action. The inbound operation name on the proxy service is used as the outbound operation name invoked on the business service. Apart from the Routing action there are no other actions in this proxy service. By that, both the request and the response messages in the $body variable are not touched by the OSB. This guarantees that the overhead of adding OSB as a service virtualization layer has minimal impact on the performance.

See also

See recipe Creating a proxy service with a WSDL-based interface, if the proxy should offer a different web service interface than the external service provider.

For deploying and testing the service check the next two recipes in this chapter.

Deploying the OSB configuration from Eclipse OEPE

Before we can test an OSB service, we need to deploy it to a running OSB server. Such a server can either be locally on the same machine or it can be on another, remotely accessible server. In this recipe, we will only use the functionality provided by Eclipse OEPE to deploy our service, because it's the simplest of the possible options for deployment. Of course there exists other, more automatic and repeatable ways for deployment through WLST or Apache Ant, but in this book, the deployment through Eclipse OEPE as shown here is good enough.

Getting ready

Make sure that the OSB server is running locally on your machine. The easiest way to check that it's up and running is navigating to the OSB console in a browser window. Enter the URL http://[OSBServer]:[Port]/sbconsole (replacing [OSBServer] with the name of the server and [Port] with the port of your installation) and you should get the login window of the OSB console. Check if the OSB server is up and running, especially when running the OSB on a managed server.

Make sure that the Oracle Service Bus perspective is the active one in Eclipse OEPE. The perspective is visible in the top-right corner of the Eclipse window.

Make sure that the project with the result from the previous recipe is available in Eclipse OEPE. If not then it can be imported from here: \chapter-1\getting-ready\pass-through-proxy-service-created.

How to do it...

First we need to create the server reference inside Eclipse OEPE and after that we can deploy the OSB configuration with its projects to the server.

In Eclipse OEPE, perform the following steps to create a server:

Switch to the Servers tab and right-click in the empty window.Select New | Server.In the Define a New Server window, select the right WebLogic Server version (Oracle WebLogic Server 11gR1 PatchSet 3 in our case, this might vary).Click on the Next button twice.Select the Local option and select the Domain Directory of the local OSB server installation. If the Domain Directory drop-down list is empty, then click on Browse button to navigate to the domain directory on your machine:Click on the Finish button.

Now the local OSB server is configured in Eclipse OEPE. The next step is to deploy the OSB configuration to this sever. Still in Eclipse OEPE, perform the following steps:

On the Servers tab, right-click on the server item that you just created and select Add and Remove.In the Available list on the left, click on the osb-cookbook-configuration OSB configuration.Click on Add to move it to the Configured list on the right and click on the Finish button.The OSB configuration is deployed to the running OSB server and after a while the status will change from [Started] to [Started, Republish].Right-click on the OSB server and select Publish.After a while the status will change to [Started, Synchronized], indicating that Eclipse OEPE and the OSB server are synchronized.Expand the tree and the status of each single OSB project withinthe OSB configuration is shown:

The OSB configuration is now successfully deployed and ready to be used.

How it works...

Behind the scenes, Eclipse OEPE is creating a JAR file (a Java Archive) with all the artifacts which belong to the OSB configuration and deploys that archive to the OSB server.

The mechanism to deploy directly from Eclipse should only be used during development. Later when deploying to integration, quality assurance, or a production system, of course, a more automatic and reproducible way is necessary. This can be achieved through Apache Ant and WLST.

There's more...

In this section, we will show the alternative ways for deploying a project to an OSB server.

Deploying to a remote server from Eclipse OEPE

Eclipse OEPE can also be used to deploy to a remote server. Just click on the Remote option when defining the WebLogic Server in the New Server wizard:

Creating an OSB Configuration Jar and use the OSB console to deploy it

An OSB configuration can also be deployed by using the OSB console. In Eclipse OEPE, perform the following steps:

In the Project Explorer, right-click on the OSB Configuration that you want to deploy to and select Export | Oracle Service Bus – Configuration Jar.In the pop-up window, select the resources to export, enter the location of the configuration jar into the Jar File field and click on the Finish button.

In the OSB console, perform the following steps to import theConfiguration Jar that we just created:

Select the menu System Administration on the left-hand side. You might have to use the scroll bar in order to see all the menu items.Click on Create in the Change Center to start a new change session.Click on the Import Resources button and use Browse to select the file created in the export (c:\temp\sbconfig.jar).Click on the Next button.Check that the right sources will be imported:Click on the Import button to start the import.The successful import is confirmed by the message the import was completed successfully.Click on the Activate button in the Change Center.Enter a text describing the changes into the Description field and click on the Submit button to activate the changes.

If we need to adapt some properties like endpoint URI to match the target environment, we can use a customization file and apply that when doing the deployment.