现在的位置: 首页 > 综合 > 正文

Introduction to Apache Axis2

2013年05月29日 ⁄ 综合 ⁄ 共 8330字 ⁄ 字号 评论关闭
文章目录

http://www.redhat.com/magazine/021jul06/features/apache_axis2/

Web services is gaining momentum and many large vendors now offer web services stacks as part of their solution portfolios. The open source world has played a key role in web services by providing some excellent web services stacks that are on par with—and sometimes exceed—the quality and innovative aspects of proprietary offerings.

Apache Axis2,[1] the leading open source platform, provides the basis for the web services stack and supports both SOAP (Simple Object Access Protocol) and REST (Representational State Transfer). It is the foundation for building a complete web services stack with Apache Rampart/Rahas[2], Sandesha2[3], and Kandula2[4] providing support for all key web services specifications. With its 1.0 release on May 6, 2006, Axis2 is production-ready.

This article takes a closer look at the Axis2 architecture and the many advantages it has to offer to speed up your Service Oriented Architecture strategy. The focus will be on how to use Axis2 effectively in given scenarios.

Axis2 in a Nutshell

Axis2 is a third-generation open source SOAP stack built on the experience of Apache Axis[5] and Apache SOAP[6]. It has a highly modular and flexible architecture, making it easy to support web services specifications as modules. Axis2 architecture took a radical approach from Axis to provide more scalability, to provide improved performance, and to better support the changes that were happening in the web services landscape. The web services was moving from mostly synchronous-RPC style interactions to a message-oriented approach, which encouraged both synchronous and asynchronous interactions. The Axis2 core architecture reflects these dynamics and the engine provides flexibility to support different message-exchange patterns commonly referred to as MEPs[7] .

The "Big Picture"

The core Axis2 architecture is best described using the following diagram. The digram shows the core component of the Axis2 engine and also how a message is passed through the engine until it is received by the Message Receiver, which determines the course of action it should take. Understanding this is key when working with Axis2.

The chain of handlers (interceptors) provides an extensible model for message processing that provides an easy—yet powerful—way for users to extend or change the current behavior.

Everything else is built on top of the core component. For simplicity and relevance, only the core architecture is described here.

Key Concepts and Architectural Points to Remember

Axis2 is built based on several key concepts. Understanding these key concepts makes it easy for a user to better leverage the Axis2 architecture and maximize the extensibility it provides.

  • The Axis2 engine does not assume a particular message-exchange pattern; this allows a user to support any message exchange pattern. The MessageReceiver interface provides an ideal extension point for users to define their own message exchange patterns. Axis2 currently supports IN_ONLY and IN_OUT message-exchange patterns.

  • The MessageReceiver interface also provides the flexibility for the user to do as they please with the incoming message. For example, a user could implement the message receiver to simply ignore the message, log the message, invoke some business logic, or simply redirect the message somewhere else. The possibilities are endless. Currently, Axis2 uses this flexibility to invoke spring beans, to invoke a method in a POJO, or simply to consume the raw XML message.

  • Support for both asynchronous and synchronous interactions is a key requirement in web services as both styles have strong use-cases. Axis2 provides this flexibility at the transport layer by allowing responses asynchronously via the same transport or via a different transport. For example, if a request comes via HTTP and the processing is done asynchronously, the reply can be sent via HTTP or it could leverage a completely different transport, such as JMS.

  • AXIOM is a new object model that was introduced with Axis2. It builds on the streaming-pull parser and improves performance tremendously over Axis. The differed parsing reduces the memory footprint when processing SOAP messages.

  • The extensibility of the SOAP processing model occurs via the concept of handlers and phases. Handlers can be thought of as a pipeline that passes the message context through. A phase is a logical grouping of handlers and contains rules such as "Phase First", "Phase Last", "Before", and "After", which defines a very flexible execution framework. Each handler is responsible for processing a certain aspect of the SOAP message. For example, the Addressing handlers deal with the WS-Addressing headers in the SOAP message.

  • The concept of modules, which is designed to add support for Web Service extensions, improves the extendability of the Axis2 core architecture to support various Web Service specifications such as WS-Addressing or WS-Security. It is basically a logical grouping of a set of handlers and related classes that extend the SOAP processing model to support a Web Service extension. These modules can be engaged dynamically per service, giving the end user very fine granularity in controlling the behavior of a Web Service.

  • Hot deployment for modules and services is another key improvement over the Axis 1.x family. It introduces a new archive format for packaging services and modules.

  • Support for exposing POJOs as web services is another point worth mentioning. The built-in support provided via RPCMessageReceiver and the clean API provided to add a POJO as a Web Service make it relatively easy to expose a POJO with few lines of code.

  • Support for multiple transports such as HTTP, JMS, SMTP, and TCP greatly improves the usability of Axis2 in a wide variety of environments.

  • Axis2 is easily embeddable in a standalone application or can be packaged in your own Web Archive file, giving the end user the flexibility in deciding the deployment and packaging options.

How can Axis2 accelerate your SOA Strategy

Now that you have the basic ideas about Axis2, let's look at some case studies and questions from the community. We can use these to learn more about the advantages of Axis2 while demonstrating how Axis2 can help you effectively implement your Service Oriented Architecture strategy.

Use Case 1

Company A has an existing application and there is a requirement to expose certain business interfaces as web services. This application is a non-Web application.

How Axis2 can help

Axis2 provides easy support for exposing a POJO as a Web Service. Axis2 is also highly embeddable. The developer could easily include the Axis2 JARs and, in a few simple steps, can leverage the API calls to register a POJO as a Web Service and embed Axis2 in the existing application. Also, the developer has several choices for transports. They could use TCP, JMS, or even HTTP via the SimpleHttpServer included in Axis2. The SimpleHttpServer is not production-ready and may not scale well under increased traffic. However, current work is being done to improve it to production strength. Below is a simple example:

Use Case 2

Company B has a Web application and now they want to expose some of the business logic as web services to 3rd-party companies. For easy maintenance and convenience, Axis2 has to be bundled within the same WAR file.

How Axis2 can help

As mentioned above, Axis2 has an easy way of exposing POJOs as web services. Axis2 can also be easily embedded in a WAR file. You simply need to add the Axis2 JARs in the lib directory and then provide the Services.xml under the WEB-INF folders as illustrated below. You also need to add the AxisServlet in your web.xml.

Use Case 3

You need to develop an application from scratch based on the web services architecture.

How Axis2 can help

Axis2 always encourages schema/WSDL first approach and has excellent support for it. Once you design your schema/WSDL, you could leverage the code generation tools to provide with the code; the developer needs only to fill in the business logic. The application can be packaged in a WAR file and deployed in a Web container or it could be run on its own using a transport other than HTTP.

Use Case 4

What are my choices in manipulating the SOAP body? How does Axis2 facilitate this?

How Axis2 can help

Axis2 provides you several choices. Basically if you prefer to work with raw XML, then raw XML based Message Receivers will provide you with an AXIOM representation of the XML that is very easy to navigate and manipulate.

If you desire to work with objects themselves, then Data Binding can be used effectively. Axis2 comes with ADB (Axis Data Binding), which has limited data-binding support, but you could easily use XMLBeans or JAXMe or JibX as your data binding framework. Below is an example of the basic differences in the two approaches:


No login required. Want to see your comments in print? Send a letter to the editor.

Summary

Apache Axis2 is an open source Web-Services platform that provides the foundation to build a complete web services stack that supports both SOAP and REST based applications. Axis2 has very strong support in the key areas within the web services paradigm, which makes it stand above the rest. It is strongly recommended for any organization that is interested in developing web services-based applications.

References

[1] Apache Axis2 (http://ws.apache.org/axis2/)

[2] Apache Rampart/Rahas (http://ws.apache.org/axis2/modules/rampart/1_0/security-module.html)

[3] Apache Sandesha2 (http://ws.apache.org/sandesha/sandesha2/)

[4] Apache Kandula2 (http://ws.apache.org/kandula/2/index.html)

[5] Apache Axis (http://ws.apache.org/axis/)

[6] Apache SOAP (http://ws.apache.org/soap/)

[7] MEP (Message Exchange Patterns) (http://www.w3.org/TR/2004/WD-wsdl20-patterns-20040326/)

抱歉!评论已关闭.