Java/Web Services SOA/POJO Web service

Материал из Java эксперт
Версия от 07:27, 1 июня 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

An example POJO Web service: how to expose the methods of a Java class as a Web service using Axis2.

 
Sample: POJO (Plain Old Java Object)
====================================
Introduction
============
This is an example POJO Web service. It shows how to expose the methods of a Java class as a Web
service using Aixs2.

Prerequisites  
=============
To build the sample service you must have ant-1.6.x installed in your system. 
To set AXIS2_HOME in Unix/Linux type:
$export AXIS2_HOME=<path to axis2 distribution>
Building the Service
====================
To build the sample service, type: $ant generate.service or just ant
This will build the AddressBookService.aar in the build directory and copy it to the
<AXIS2_HOME>/repository/services directory.
You can start the Axis2 server by running either axis2server.bat (on Windows) or axis2server.sh
(on Linux)that are located in <AXIS2_HOME>/bin directory.
The WSDL for this service should be viewable at:
http://<yourhost>:<yourport>/axis2/services/AddressBookService?wsdl 
(e.g. http://localhost:8080/axis2/services/AddressBookService?wsdl)
src/sample/addressbook/rpcclient/AddressBookRPCClient.java is a Client that uses RPCServiceClient
to invoke the methods of this web services just like the method invocations of a Java object.

Running the Client
==================
To compile and run, type
$ant rpc.client
src/sample/addressbook/adbclient/AddressBookADBClient is Client that uses a generated stub with ADB
to invoke the methods of this web service.
To generate the stub, compile and run, type
$ant adb.client -Dwsdl=http://<yourhost>:<yourport>/axis2/services/AddressBookService?wsdl
Help
====
Please contact axis-user list (axis-user@ws.apache.org) if you have any trouble running the sample.





How to expose the getters and setters of a Service: this demo uses the Spring to initialize the property of the Service

 
POJO Web Services using Apache Axis2- Sample 2
==============================================
This sample contains source code for the xdocs/1_1/pojoguide.html document found in 
the extracted Axis2 Documents Distribution. For a more detailed description on the 
source code kindly see this "POJO Web Services using Apache Axis2" document.
In this specific sample you"ll be shown how to take a POJO  (Plain Old Java Object) 
based on the Spring Framework, and deploy that as an AAR packaged Web service on Tomcat. 
This is a quick way to get a Web service up and running in no time. 
Introduction
============
This sample shows how to expose the getters and setters of WeatherSpringService that 
takes Weather type Java Object as the argument and the return type. It uses the Spring 
framework to initialize the weather property of the WeatherSpringService.

Pre-Requisites
==============
Apache Ant 1.6.2 or later
Spring-1.2.6.jar or later 
You need to have this jar in your build and runtime class path. The easiest way to do this 
is to copy it to Axis2_HOME/lib directory.
Building the Service
====================
Type $ant from Axis2_HOME/samples/pojoguidespring

Running the Client
==================
Type $ant rpc.client from from Axis2_HOME/samples/pojoguidespring
Help
====
Please contact axis-user list (axis-user@ws.apache.org) if you have any trouble running the sample.





In this sample, we are deploying a POJO after writing a services.xml and creating an aar

 
Axis2 Quick Start Guide- Sample 1
=================================
This sample contains source code for the xdocs/1_1/quickstartguide.html document found in 
the extracted Axis2 Documents Distribution. For a more detailed description on the 
source code kindly see this "Axis2 Quick Start Guide" document.
Introduction
============
In this sample, we are deploying a POJO after writing a services.xml and
creating an aar. We also test the getPrice and update methods using a browser.
Pre-Requisites
==============
Apache Ant 1.6.2 or later
Building the Service
====================
Type "ant generate.service" or just "ant" from Axis2_HOME/samples/quickstart directory 
and then deploy the Axis2_HOME/samples/quickstart/build/StockQuoteService.aar
Generate WSDL
==============
Type "ant generate.wsdl" from Axis2_HOME/samples/quickstart directory which generates a 
WSDL file for the above Web service and it will be placed in Axis2_HOME/samples/quickstart/build 
directory.
Running the Client
==================
- From your browser, If you point to the following URL:
http://localhost:8080/axis2/services/StockQuoteService/getPrice?symbol=IBM
You will get the following response:
<ns:getPriceResponse><ns:return>42.0</ns:return></ns:getPriceResponse>
- If you invoke the update method like so:
http://localhost:8080/axis2/services/StockQuoteService/update?symbol=IBM&price=100
And then execute the first getPrice url. You can see that the price got updated.
Help
====
Please contact axis-user list (axis-user@ws.apache.org) if you have any trouble running the sample.





This sample shows how to expose a Java class as a web service

 
POJO Web Services using Apache Axis2- Sample 1
=============================================
This sample contains source code for the xdocs/1_1/pojoguide.html document found in 
the extracted Axis2 Documents Distribution. For a more detailed description on the 
source code kindly see this "POJO Web Services using Apache Axis2" document.
The above mentioned document shows you how to take a simple POJO (Plain Old Java 
Object), and deploy it on Apache Tomcat as a Web service in the exploded directory 
format. This is a quick way to get a Web service up and running in no time. 
Introduction
============
This sample shows how to expose a Java class as a web service.  
The WeatherService Java class provides methods to get and set a Weather 
type Java objects. The client uses RPCServiceClient to invoke those two 
methods just as Java object method invocation.
Prerequisites
==============
Apache Ant 1.6.2 or later
Building the Service
====================
Type $ant from Axis2_HOME/samples/pojoguide

Running the Client
==================
Type $ant rpc.client

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