|
Table of Contents
|
Webservice?
Web services combine the HTTP communication protocol and the XML data format
SOAP (Simple Object Access Protocol)
A framework for exchanging XML-based information in a network. Client requests and web service responses are transmitted as Simple Object Access Protocol (SOAP) messages over HTTP to enable a completely interoperable exchange between clients and web services, all running on different platforms and at various locations on the Internet.
WSDL (Web Service Description Language)
* an XML-based language for describing network services
* WSDL descriptions of capabilities and locations of services
* like an interface description language for Web services
* communication using SOAP or direct HTTP
UDDI (Universal Description, Discovery, and Integration)
* provides a registry mechanism for clients and servers to find each other
* uses SOAP for communication
JAX-WS in JavaEE
JAX-WS stands for Java API for XML Web Services. JAX-WS is a technology for building web services and clients that communicate using XML. JAX-WS allows developers to write message-oriented as well as RPC-oriented web services.
The starting point for developing a JAX-WS web service is a Java class annotated with the javax.jws.WebService annotation. The @WebService annotation defines the class as a web service endpoint.
A service endpoint interface or service endpoint implementation (SEI) is a Java interface or class, respectively, that declares the methods that a client can invoke on the service. An interface is not required when building a JAX-WS endpoint. The web service implementation class implicitly defines an SEI.
You may specify an explicit interface by adding the endpointInterface element to the @WebService annotation in the implementation class. You must then provide an interface that defines the public methods made available in the endpoint implementation class.
We use Use wsgen to generate the artifacts required to deploy the service and then use the endpoint implementation class and the wsimport tool to generate the web service artifacts that connect a web service client to the JAX-WS runtime.

Axis2
Message Exchange Patterns
Although all SOAP messages carry the same structure, the ways in which they are used can be combined into a number of different "message exchange patterns", or MEPs. The two major message exchange patterns are:
In-Out: in this MEP, the client sends a SOAP message to the server, which processes the message and sends a response back. This is probably the most commonly used MEP, and is useful for tasks such as searching for information or submitting information in situations in where acknowledgment is important.
In-Only: In this MEP, the client sends a message to the server without expecting a response. You may use this MEP for activities such as pinging a server to wake it up, reporting logging information for which you do not need an acknowledgment and so on.
Within these two MEPs, you also have several variables to consider:
Blocking versus non-blocking (Synchronous / Asynchronous): When the client sends a message, the application may wait to receive a response before moving on, or it may simply send a message and move on by specifying a callback action to be completed when the response is received.
There are currently two approaches to invoking a Web Service in a non-blocking manner. The first is the client programming model, where a client invokes the service in a non-blocking manner.The second way is the transport level non-blocking invocation here invocation occurs in two transports (it could either be two single-channel transports like SMTP, or two double-channel transports like HTTP). Axis2 introduces a very convenient client API for invoking services: "ServiceClient" and "OperationClient" classes. The ServiceClient API is intended for regular usage when you just require to send and receive XML but the operation client is meant for advanced usage.
wsdl2java
It will create among other things: service.xml, skeleton class to be edited, schemas, types, some classes,….
service.xml
Deployment description for axis2. every webservice must have this. you can write your own manually
AXIOM
The advantage of AXIOM over other XML InfoSet representations is that it is based on the PULL parser technique, whereas most others are based on the PUSH parser technique. The main advantage of PULL over PUSH is that in the PULL technique, the invoker has full control over the parser and it can request the next event and act upon that, whereas in case of PUSH, the parser has limited control and delegates most of the functionality to handlers.
Deployment Model
Hot deployment: This refers to the capability to deploy services while the system is up and running.
Hot update: This refers to the ability to make changes to an existing Web Service without even shutting down the system. Not recommended in production.
Transport
In Axis2 every transport consists of two parts, namely "Transport Senders" and "Transport Receivers".One of the important aspects of Axis2 is that its core is completely independent of the transport sender and receiver. It supports these protocols: http,tcp,smtp,jms,xmmp.
Databinding
ADB: ADB (Axis2 Data Binding) is a simple and performant one .
XMLBeans: XMLBeans is preferred if we want to use full schema support as XMLBeans claims that it supports complete schema specification.
JaxMe: JaxMe support has been added to XMLBeans, and it serves as another option for the user.
JibX: This is the most recent addition to the family of data binding extensions.
Stub and Skeleton
As you might already know, a WSDL description of a service provides a precise definition of a Web Service. Axis2 can process the WSDL and generate java code that does most of the work for you. At the server side, we call them Skeletons, and at the client side, Stubs.
This method of writing a Web service with Axis2 involves four steps:
1. Generate the skeleton code.
2. Add business logic.
3. Create a *.aar archive (Axis Archive) for the Web service.
4. Deploy the Web service.
Generating Services
Broadly there are two ways:
1. Code generation (wsdl2java)
Suppose "Axis2UserGuide.wsdl" is in "D:\java\workspace\Axis2", then
D:\java\workspace\Axis2>wsdl2java.bat -uri Axis2UserGuide.wsdl -p org.apache.axis2.axis2userguide -o . -d adb -s -wv 1.4.1 -ss -sd
will generate all the artifacts under "Axis2" directory:
D:\java\workspace\Axis2\
+---resources
+---src
+---org
+---apache
+---axis2
+---axis2userguide
2. Using xml based primary API
You need to write implementation classes and service.xml first and then create aar file and at the end deploy!
But to be more precise, there are five ways:
- Deploying Plain Old Java Objects (POJO)
- We need services.xml
- Package services.xml with pojo into an aar and deploy
- wsdl is optional
- Building the service using AXIOM's OMElement (This is creating service from scratch-manulally)
- NO need for wsdl
- Create services.xml
- Write services. Axis2 uses AXIOM, or the AXIs Object Model, a Dom-like structure that is based on the StAX API (Streaming API for XML). Methods that act as services must take as their argument an OMElement, which represents an XML element.
- Implement your logic
- Bundle aar file and deploy
- Generating the service using Axis2 Databinding Framework (ADB)
- Need wsdl
- Use wsdl2java to generate skeletons (we can always generate services.xml from this)
- Implement logic
- Bundle and deploy
- Generating the service using XMLBeans
- Need wsdl
- Generate skeleton using wsdl2java using option -d xmlbeans
- Implement your logic
- Bundle and deploy
- Generating the service using JiBX
- Need wsdl
- Generate skeleton using wsdl2java using option -d jibx
- Implement your logic
- Bundle and deploy
Generating Client
Broadly there are two ways:
- code generation(wsdl2java, not specifying -ss will generate stubs)
- Using xml based primary API
But precisely, there are four methods:
- Building an AXIOM based client (Manual coding)
- Generating a client using Axis2 Databinding Framework (ADB)
- Need a wsdl
- You need to run wsdl2java to create stubs. It will create among other things: stub class to be edited, types, build.xml for compiling,…
- Write and run client code (depends and calls the stub)
- Generating a client using XMLBeans. XMLBeans uses a different architecture from ADB. In XMLBeans, processing centers around documents, which are created through the use of factories, and which include inner classes for the objects they contain. The process is still the same — you create a request, and send it using the stub — the code is just a bit more complex.
- Need a wsdl
- You need to run wsdl2java to create stubs
- Write and run client code
- Generating a client using JiBX
- Need a wsdl
- You need to run wsdl2java to create stubs
- Write and run client code





