Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

J2EE Web services in Geronimo, Part 2: Message handlers, attachments, security, and registry access

Stefan Schmidt (geronimo@stsmedia.net), Developer and author, 自由职业者
Stefan Schmidt is a Ph.D. student specializing in enterprise development and conception, distributed systems, and Web services technologies. He is currently working as a tutor for subjects including advanced Internet technologies and distributed computing architecture.

Summary:  Learn how to add message handlers, attachment support, Web services security, custom exceptions, and Universal Description, Discovery and Integration (UDDI) registry access into a classic Java™ 2 Platform, Enterprise Edition (J2EE)-based application. This tutorial, Part 2 of the series, shows you how to extend the BookShop application deployed on Apache Geronimo to reflect these additions.

View more content in this series

Date:  04 Oct 2005
Level:  Intermediate PDF:  A4 and Letter (797 KB | 38 pages)Get Adobe® Reader®

Activity:  6829 views
Comments:  

Before you start

In this tutorial, you'll learn about Web services-related projects, APIs, and specifications, such as Simple Object Access Protocol (SOAP) with Attachments API for Java (SAAJ), SOAP with Attachments (Sw/A), Apache Web Services for Java (WSS4J), and Java API for XML Registries (JAXR) presented in various scenarios and designed to extend the existing BookShop application you started in Part 1.

About this series

Part 1 of this series demonstrated the integration of service-consumer and service-provider Web services into the existing J2EE-based BookShop application on the Apache Geronimo application server. This tutorial, Part 2 of this series, shows you several additional elements that are important when using enterprise Web services in Geronimo: message handlers, attachments, security, custom exceptions, and registry access.


About this tutorial

The current BookShop application developed in Part 1 allows customers to search for books based on categories using a Web interface and a Web services interface. Search results include the book title, author names, ISBN, description, and price in US dollars. Now learn how to extend the BookShop Web service by incorporating message handlers, binary attachment support, message-level security, and UDDI registry access and logging. The examples provide a brief discussion of these new features as well as their implementations and configurations in Geronimo.

The tutorial is structured as follows:

  • Extend BookShop with JAX-RPC message handlers shows how you can add SOAP message-logging capabilities and transaction management to the BookShop application using message handlers. Message handlers can intercept SOAP messages at two points: before they are processed and after they are processed by the BookShop business logic. They provide powerful message-processing capabilities and, thus, allow SOAP message security, logging, or transaction management, among other functions.
  • Add attachments to the BookShop Web service demonstrates adding attachments as part of the SOAP response message sent to the BookShop client application. This section introduces SAAJ to the mechanisms explained in the Sw/A specification. You'll see two approaches demonstrated for including attachments using SOAP messages.
  • Secure the BookShop Web services explains how the WS-Security standard is applied to secure the SOAP messages sent and received by the BookShop application. You'll get an introduction to user authentication to achieve access control, digital signatures for message integrity, and encryption and decryption mechanisms to ensure message confidentiality for SOAP messages.
  • Deliver custom exceptions describes how custom exceptions, or checked exceptions, enhance the usability of the BookShop Web services and provide a powerful mechanism to support the communication between BookShop clients and the BookShop application hosted on Geronimo.
  • Access a business registry from the BookShop outlines how the BookShop Web services are supported by the JAXR specification and its Apache Scout-based implementation, which are shipped with Geronimo. Learn how to publish a Web service and how to find Web services using Geronimo's JAXR client API.

Prerequisites

Geronimo developers and Java developers with prior experience in J2EE platform development, this tutorial is for you! General knowledge of distributed programming concepts and the role of Web services in this context is an added plus, but not required.


System requirements

To run the code samples in this tutorial, you first need to download and install the following applications and libraries (see Resources for links to these downloads):

  • Java 2 Platform, Standard Edition (J2SE) 1.4.2_08 SDK
  • Apache Geronimo M5
  • Apache Ant
  • Apache Axis 1.2.1
  • Sun's Java Web Services Developer Pack (Java WSDP)
  • Eclipse Development Platform (optional)

Referring to Table 1, make sure that the following environmental variables are set in your shell:


Table 1. Setting the environmental variables
Variable nameDescription
GERONIMO_HOME Set to the root folder of your Geronimo installation
ANT_HOME Set to the root folder of your Ant installation
JAVA_HOME Set to the root folder of your Java installation
AXIS_HOME Set to the root folder of your Axis installation
AXIS_LIBRARIES Set to all libraries in AXIS_HOME/lib
PROJECT_HOME Set to the root folder of the BookShop application
PATH Include JAVA_HOME/bin, ANT_HOME/bin, JWSDP_HOME, and JWSDP_HOME/jaxrpc/bin

After installing and setting up these applications, you need to set up a few more things:

  • Create a folder in %GERONIMO_HOME%/repository/bouncycastle/jars, and copy the bcprov-jdk13-128.jar from the %PROJECT_HOME%/lib distribution into this folder. Edit the %PROJECT_HOME%/meta/ear/geronimo-application.xml, and include the following dependency to the list: <dependency><uri>wss4j/jars/bcprov-jdk13-128.jar</uri></dependency>.
  • Create a folder in %GERONIMO_HOME%/repository/wss4j/jars, and copy the opensaml-1.0.1.jar, the wss4j.jar, and the xmlsec-1.2.1.jar from the WSS4J distribution into this folder.
  • Edit the project build.xml, and set the correct paths for your Geronimo and your Axis installations. Also, look into %GERONIMO_HOME%/repository/tranql/rars, and adjust this file name in the build.xml file accordingly.

In this tutorial, you have the opportunity to choose the BookShop database engine in either Apache Derby or MySQL (note that Derby ships with Geronimo). The following steps provide configuration details for both databases:

  • Edit the project build.xml, and set the database property to the database of your choice.

Derby-specific installation:

  • Unzip derby.zip found at %PROJECT_HOME%/etc into the %GERONIMO_HOME%/var/derby directory.

MySQL-specific installation:

  • Download MySQL and MySQL Connector/J driver.
  • Create a database called bookshopdb in MySQL, and then run the supplied database script (etc/bookshopdb.sql) to create and populate the required relational database tables.
  • Create a folder in %GERONIMO_HOME%/repository/mysql/jars, and copy the mysql-connector-java-your_version_number.jar driver to this directory.

1 of 10 | Next

Comments



Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Open source, SOA and Web services
ArticleID=133201
TutorialTitle=J2EE Web services in Geronimo, Part 2: Message handlers, attachments, security, and registry access
publish-date=10042005
author1-email=geronimo@stsmedia.net
author1-email-cc=troy@backstopmedia.com

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Try IBM PureSystems. No charge.