Developing Web
Services with
Apache Axis2
By
Kent Ka Iok Tong
Copyright © 2005-2008
TipTec Development
Publisher: TipTec Development
Author's email: freemant2000@yahoo.com
Book website: http://www.agileskills2.org
Notice: All rights reserved. No part of this publication may be
reproduced, stored in a retrieval system or transmitted, in any
form or by any means, electronic, mechanical, photocopying,
recording, or otherwise, without the prior written permission
of the publisher.
ISBN: 978-99937-929-1-8
Edition: Second edition March 2008
Developing Web Services with Apache Axis2 3
Foreword
Learn web services and Apache Axis2 easily
If you'd like to learn how to create web services (in particular, using Apache
Axis2) and make some sense of various standards like SOAP, WSDL, MTOM,
WS-Addressing, WS-Security, WS-Policy, XML Encryption and XML Signature,
then this book is for you. Why?
• It has a tutorial style that walks you through in a step-by-step manner.
• It is concise. There is no lengthy, abstract description.
• Many diagrams are used to show the flow of processing and high level
concepts so that you get a whole picture of what's happening.
• The first 46 pages are freely available on http://www.agileskills2.org. You can
judge it yourself.
Unique contents in this book
This book covers the following topics not found in other books on Axis:
• How to work with Axis2 1.3.
• How to use Eclipse Europa (WTP 2.0) with Axis2.
• How to invoke asynchronous operations using WS-Addressing.
• How to encrypt and sign SOAP messages using Rampart.
• How to send user authentication information using Rampart.
• How to send and receive binary files using MTOM.
• How to integrate Axis2 with Spring.
Target audience and prerequisites
This book is suitable for those who would like to learn how to develop web
services in Java.
In order to understand what's in the book, you need to know Java and to have
edited XML files. However, you do NOT need to know the more advanced XML
concepts (e.g., XML schema, XML namespace), servlet, Tomcat or PKI.
4 Developing Web Services with Apache Axis2
Acknowledgments
I'd like to thank:
• The Axis developers for creating Axis.
• The WSS4J developers for creating WSS4J.
• Anne Thomas Manes, an expert in web services, for reviewing the book (first
edition).
• Helena Lei for proofreading this book.
• Eugenia Chan Peng U for doing book cover and layout design.
Developing Web Services with Apache Axis2 5
Table of Contents
Foreword.........................................................................................3
Learn web services and Apache Axis2 easily............................3
Unique contents in this book......................................................3
Target audience and prerequisites.............................................3
Acknowledgments.......................................................................4
Chapter 1 Designing the interface for a simple web service..........9
What's in this chapter?.............................................................10
Providing cross platform operations across the Internet..........10
RPC style web service..............................................................11
Document style web service.....................................................14
Determining the operation for a document style web service..17
Port type...................................................................................18
Binding......................................................................................19
Port...........................................................................................20
Target namespace....................................................................22
WSDL.......................................................................................24
Summary..................................................................................25
Chapter 2 Implementing a web service........................................27
What's in this chapter?.............................................................28
Installing Eclipse.......................................................................28
Installing Axis2..........................................................................28
Installing the Axis2 plug for Eclipse..........................................30
WSDL file for the web service..................................................31
RPC version of the web service...............................................35
Creating the WSDL file visually................................................36
Validating the WSDL file...........................................................45
Generating a service stub.........................................................46
Implementing the web service..................................................52
Deploying a web service...........................................................53
Creating a client using a client stub..........................................55
Undeploying a web service.......................................................58
Summary..................................................................................59
Chapter 3 Optimizing the development environment...................61
What's in this chapter?.............................................................62
Placing the class files into Axis directly....................................62
Making changes take effect immediately.................................64