Java/Web Services SOA/AXIS2

Материал из Java эксперт
Перейти к: навигация, поиск

A simple service that returns a text which contains the version number and the built date of the Axis2 Distribution used.

 
Sample: Version
===============
Introduction
============
A simple service that returns a text which contains the version number and the built 
date of the Axis2 Distribution used.
In other words, this is a simple service used by many to test whether the distribution they got is setup 
and working properly. It contains a single method that simply returns version and built 
date of the Axis2 distribution used.

Pre-Requisites
==============
Apache Ant 1.6.2 or later
Running the Sample
==================
Type $ant from Axis2_HOME/samples/version

Help
====
Please contact axis-user list (axis-user@ws.apache.org) if you have any trouble running the sample.





AXIS2 Event

 
Steps to build and run the Savan-Eventing sample
------------------------------------------------
To build
--------
1. Move to the sample folder.
2. Create a subfolders "build/lib".
3. Copy all the jars from a compatible Axis2 distribution to "build/lib".
4. Copy the savan jar file to "build/lib".
5. Run "ant" to build the sample.

To run
------
1. Start a Axis2 server.
2. Deploy savan and addressing modules.
3. Deploy the three services that were created in the "build" folder.
4. Run the "samples.eventing.Client" class, you can pass the repository with a "-r" parameter and the server port with a "-p" parameter.





How to write a Web service and Web service client with Apache Axis2 using XML based client APIs (Axis2"s Primary APIs)

 
Axis2 User"s Guide Sample
=========================
This sample contains the source code relevant to xdocs/1_1/adv-userguide.html, 
more specifically to xdocs/1_1/dii.html and xmlbased-server.html which are sections 
of the Axis2 Advanced User"s Guide found in the Documents Distribution.
The sample explains how to write a Web service and Web service client with 
Apache Axis2 using XML based client APIs (Axis2"s Primary APIs).
Introduction
============
The following sample clients are located at 
AXIS2_HOME/samples/userguide/samples/userguide/src/userguide/clients directory. 
EchoBlockingClient.java -- Demonstrates the request-response, blocking client which 
is written using Axis2"s primary APIs.
EchoBlockingDualClient.java -- Demonstrates the request-response, blocking client which 
uses two transport connections and written using Axis2"s primary APIs.
EchoNonBlockingClient.java -- Demonstrates the request-response, non-blocking invocation 
which is written using Axis2"s primary APIs.
EchoNonBlockingDualClient.java -- Demonstrates the request-response, non-blocking invocation 
using two transport connections and is written using Axis2"s primary APIs.
MailClient.java -- Represents a client for invoking 
PingClient.java -- Represents a simple one-way client which is written using Axis2"s primary APIs.
RESTClient.java -- Represents a client for invoking a REST Web service
TCPClient.java -- Demonstrates a client for invoking a Web service using TCP
example1, example2 and example3 directories inside Axis2_home/samples/userguide/src/userguide 
contain the Web services which are invoked by the above clients.

Pre-Requisites
==============
Apache Ant 1.6.2 or later
Building the Service
====================
* Type "ant generate.module" from Axis2_HOME/samples/userguide to generate the logging module.
* Add the logging phase to the ../../conf/axis2.xml. For more details please refer to the 
  http://ws.apache.org/axis2/1_2/modules.html
* Type "ant generate.service" or just "ant" from Axis2_HOME/samples/userguide
* Then go to AXIS2_HOME/bin directory and run either axis2server.bat or axis2server.sh depending on your platform.
Alternatively you can copy the the generated service archives in to a servlet container.
If you go to http://localhost:8080/axis2/, you should see MyService, MyServiceWithModule are deployed. 

Running the Clients
===================
Type the following ant commands from Axis2_HOME/samples/userguide to run the clients one by one.
 * "ant run.client.blocking"
   This invokes MyService through a request-response, blocking client.   
 * "ant run.client.blockingdual"
   This invokes MyService through a request-response, blocking client via dual transport channels.   
 * "ant run.client.nonblocking"
   This invokes MyService through a request-response, non-blocking client.  
 * "ant run.client.nonblockingdual"
   This invokes MyService through a request-response, non-blocking client via dual transport channels.   
 * "ant run.client.ping"
   This invokes MyService through a one-way client
 
You can find more information on the above clients in Axis2 users guide, RESTFul Web services support, 
TCP Transport documents found in the Documents Distribution"s xdocs directory. Also, you may find it 
useful to try out the above services and clients while going through these documents.
Note
==============
Sometimes, if you"re having trouble running the client successfully, 
It may be necessary to clean the services repository before you generate the service, deploy it
and run the client. (i.e. delete services created from previous samples.)
Help
====
Please contact axis-user list (axis-user@ws.apache.org) if you have any trouble running the sample.





This sample demonstrates how to use WSDL2Java generated code with Castor

 
3Sample: Data Binding
====================
Introduction
============
This sample demonstrates how to use WSDL2Java generated code with Castor. 
Running of this sample assumes that you are running this within the extracted release folder (Axis2_HOME/samples/databinding).

Pre-Requisites
==============
 * Install Apache Ant 1.6.2 or later.
 * Please create a directory named lib under the directory that contains this file.
 * Download latest stax-utils jar from
   https://stax-utils.dev.java.net/servlets/ProjectDocumentList?folderID=1106 and drop that into the
   new lib directory.
 * Download version 1.0.4 of Castor jar from http://dist.codehaus.org/castor/1.0.4/castor-1.0.4.jar and drop that into the new
   lib directory.(The latest releases of castor are available at http://www.castor.org/download.html, but this example may not run   
   with versions later than 1.0.4)
You can achieve all three of the above steps by running "ant download.jars", but it will take some 
time to download those two jars, using ant.

Deploying the Service
=====================
You need to create the stock service Web service and deploy it. Typing ant generate.service or 
simply ant in the command prompt, will build the service against StockQuoteService.wsdl listed 
inside Axis2_HOME/samples/databinding and put it under Axis2_HOME/repository/services.
You need to then startup the server to deploy the service. Go to Axis2_HOME/bin folder and execute either
axis2server.bat (in Windows) or axis2server.sh(in Linux), depending on your platform.

Running the Client
==================
Typing the command "ant run.client" inside Axis2_HOME/samples/databinding runs the Axis2_HOME/samples/databinding/client/src/samples/databinding/StockClient.java class. You may use
the command scripts (as specified above) to do so. You need to supply 2 parameters to the command- url and symbol.
 * ant run.client -Durl=http://localhost:8080/axis2/services/StockQuoteService -Dsymbol=IBM
   Succeeds with a Price of 99.0. You will see "Price = 99.0"
When you call ant run.client with parameters, before running
client/src/samples/databinding/StockClient.java class, it does the following as well:
  * Generate the stubs (for the client) from the WSDL
  * Compile the client classes
  * Create a Jar of the client classes and copy it to build/client/StockService-test-client.jar
How It Works
==============
- Generate code giving -d none to get all the Axis2 APIs with OMElements.
- Create Castor objects for the schema given in the StockQuoteService.wsdl.
- Client API and the service uses those castor objects to get/set data.
- Get StAX events from the castor objects and construct OMElements from them. Those StAX events
  are fed into StAXOMBuilder which can create OM tree from it.
- Feed those OMElement in to generated code.
Note
==============
Sometimes, if you"re having trouble running the client successfully, 
It may be necessary to clean the services repository before you generate the service, deploy it
and run the client. (i.e. delete services created from previous samples.)
Help
====
Please contact axis-user list (axis-user@ws.apache.org) if you have any trouble running the sample.





This sample demonstrate usage of service lifecycle and bit of session managment

 
Sample: ServiceLifeCycle
=========================
Introduction:
============
This sample demonstrate usage of service lifecycle and bit of session managment. 
The main idea is to show where and how to use service lifecycle interface and 
session related methods. 

Prerequisites
=============
Apache Ant 1.6.2 or later
If you want to access the service in REST manner you have to deploy the service in 
application server such as Apache Tomcat. Note that it will not work with axis2server.

Deploying the Sevrice
===================== 
Deploy into Sample repository:
    
 * Type ant generate.service or simply ant from Axis2_HOME/samples/servicelifecycle
Deploy into Tomcat :
     
 * To build and copy the service archive file into Tomcat, type ant copy.to.tomcat from 
Axis2_HOME/samples/servicelifecycle which will copy the aar file into
tomcat/web-app/axis2/WEB-INF/services directory.
Running the Client
==================
Type ant run.client from Axis2_HOME/samples/servicelifecycle.
And then follow the instructions as mentioned in the console.
Advanced Guide
==============
For more details kindly see doc/servicelifecycleguide.html
Help
====
Please contact axis-user list (axis-user@ws.apache.org) if you have any trouble running the sample.