axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Davanum Srinivas" <dava...@gmail.com>
Subject Re: svn commit: r473184 - in /webservices/axis2/branches/java/1_1/xdocs/1_1/pojo: ./ src/ src/axis2POJO/ src/axis2POJO/src/ src/axis2POJO/src/META-INF/ src/axis2POJO/src/sample/ src/axis2POJO/src/sample/pojo/ src/axis2POJO/src/sample/pojo/data/ src/a
Date Fri, 10 Nov 2006 04:45:48 GMT
Chatra,

the code should go under samples. Not in xdocs.

thanks,
dims

On 11/9/06, chatra@apache.org <chatra@apache.org> wrote:
> Author: chatra
> Date: Thu Nov  9 20:43:56 2006
> New Revision: 473184
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=473184
> Log:
> adding 'POJO Web Services using Apache Axis2' document.
>
> Added:
>     webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/
>     webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/pojo.html
>     webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/
>     webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2POJO/
>     webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2POJO/build.xml
>     webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2POJO/src/
>     webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2POJO/src/META-INF/
>     webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2POJO/src/META-INF/services.xml
>     webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2POJO/src/sample/
>     webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2POJO/src/sample/pojo/
>     webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2POJO/src/sample/pojo/data/
>     webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2POJO/src/sample/pojo/data/Weather.java
>     webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2POJO/src/sample/pojo/rpcclient/
>     webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2POJO/src/sample/pojo/rpcclient/WeatherRPCClient.java
>     webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2POJO/src/sample/pojo/service/
>     webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2POJO/src/sample/pojo/service/WeatherService.java
>     webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/
>     webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/build.xml
>     webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/
>     webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/META-INF/
>     webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/META-INF/services.xml
>     webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/applicationContext.xml
>     webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/client/
>     webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/client/WeatherSpringRPCClient.java
>     webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/lib/
>     webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/sample/
>     webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/sample/spring/
>     webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/sample/spring/bean/
>     webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/sample/spring/bean/Weather.java
>     webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/sample/spring/service/
>     webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/sample/spring/service/SpringInit.java
>     webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/sample/spring/service/WeatherSpringService.java
>
> Added: webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/pojo.html
> URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/pojo.html?view=auto&rev=473184
> ==============================================================================
> --- webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/pojo.html (added)
> +++ webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/pojo.html Thu Nov  9 20:43:56 2006
> @@ -0,0 +1,601 @@
> +<?xml version="1.0" encoding=""?>
> +<html lang="en">
> +<head>
> +  <meta http-equiv="content-type" content="">
> +  <title>POJO Web Services using Axis2</title>
> +</head>
> +
> +<body lang="en">
> +<h1>POJO Web Services using Apache Axis2</h1>
> +
> +<p>Want a quick way to get a Web service up and running in no time? Well
> +then, you should consider creating a Plain Old Java Object (POJO) to deploy
> +using Apache Axis2 on Apache Tomcat. POJOs are fast to build and easy to
> +maintain, meaning you'll save a lot of time building and debugging your code.
> +This document shows you how to take a simple POJO, and deploy it on Apache
> +Tomcat as a Web service in the exploded directory format. You'll also be
> +shown how to take a POJO based on the Spring Framework, and deploy that as an
> +AAR packaged Web service on Tomcat.</p>
> +<ul>
> +  <li><a href="#introduction">Introduction</a></li>
> +  <li><a href="#pojo">The POJO</a></li>
> +  <li><a href="#pojows">POJO Web service using Apache Axis2 and Tomcat</a>
> +    <ul>
> +      <li><a href="#definingservice">Defining the Service:
> +      services.xml</a></li>
> +    </ul>
> +  </li>
> +  <li><a href="#buildpojows">Building the POJO Web Service Using Ant</a></li>
> +  <li><a href="#testingpojows">Testing the POJO Web Service Using
> +    RPCServiceClient</a>
> +    <ul>
> +      <li><a href="#limitationspojo">Limitations and Strengths of
> +      POJO</a></li>
> +    </ul>
> +  </li>
> +  <li><a href="#springpojows">Spring-based POJO Web Service</a>
> +    <ul>
> +      <li><a href="#quickintro">Quick Introduction</a></li>
> +      <li><a href="#servicedef">The Service Definition: services.xml</a></li>
> +      <li><a href="#initializingspring">Initializing the Spring application
> +        context: SpringInit</a></li>
> +      <li><a href="#testingrpc">Testing Using an RPCServiceClient</a></li>
> +    </ul>
> +  </li>
> +  <li><a href="#summary">Summary</a></li>
> +  <li><a href="#furtherstudy">For Further Study</a></li>
> +</ul>
> +<a name="introduction"></a>
> +
> +<h2>Introduction</h2>
> +
> +<p>The task of building a Web service can sometimes be overwhelming, but not
> +with POJOs! The old-school Plain Old Java Object is a simple and quick way to
> +get most, if not all, of your currently existing Java classes up on the Web
> +as readily accessible Web services. This document will show you how to build
> +a POJO-style Web service with Apache Axis2 and Tomcat, organized as
> +follows:</p>
> +<ul>
> +  <li>The POJO: This is the Java class that you'll use throughout this
> +    document</li>
> +  <li>POJO deployment</li>
> +  <li>Test the POJO Web service using an RPC based client</li>
> +  <li>Limitations of straight POJO</li>
> +  <li>Spring-based POJO Web service and deployment</li>
> +</ul>
> +
> +<p>The code for the document can be found <a
> +href="src/">here</a>, and it might help to go grab it now to
> +help you as you follow along. Let's get started.</p>
> +<a name="pojo"></a>
> +
> +<h2>The POJO</h2>
> +
> +<p>The POJO you'll be using throughout this document is a Weather service
> +POJO that consists of two classes: WeatherService and Weather. Weather
> +contains the Weather data: Temperature, forecast, rain (will it rain?), and
> +howMuchRain (See Code Listing 1).</p>
> +
> +<p><b>Code Listing 1: The Weather POJO</b></p>
> +<pre>package sample.pojo.data;
> +
> +public class Weather{
> +    float temperature;
> +    String forecast;
> +    boolean rain;
> +    float howMuchRain;
> +
> +    public void setTemperature(float temp){
> +        temperature = temp;
> +    }
> +
> +    public float getTemperature(){
> +        return temperature;
> +    }
> +
> +    public void setForecast(String fore){
> +        forecast = fore;
> +    }
> +
> +    public String getForecast(){
> +        return forecast;
> +    }
> +
> +    public void setRain(boolean r){
> +        rain = r;
> +    }
> +
> +    public boolean getRain(){
> +        return rain;
> +    }
> +
> +    public void setHowMuchRain(float howMuch){
> +        howMuchRain = howMuch;
> +    }
> +
> +    public float getHowMuchRain(){
> +        return howMuchRain;
> +    }
> +}</pre>
> +
> +<p>And here's the WeatherService class, shown in Code Listing 2.</p>
> +
> +<p><b>Code Listing 2: The WeatherService class</b></p>
> +<pre>package sample.pojo.service;
> +
> +import sample.pojo.data.Weather;
> +
> +public class WeatherService{
> +    Weather weather;
> +
> +    public void setWeather(Weather weather){
> +        this.weather = weather;
> +    }
> +
> +    public Weather getWeather(){
> +        return this.weather;
> +    }
> +}</pre>
> +
> +<p>Note that it's all just straight POJOs with field items and
> +<code>getter</code> and <code>setter</code> methods for each field. Next,
> +you'll take a look at what you need to do to make it ready for deployment on
> +Apache Axis2 and Tomcat.</p>
> +<a name="pojows"></a>
> +
> +<h2>POJO Web Service Using Apache Axis2 and Tomcat</h2>
> +
> +<p>Got the POJOs? Great. This section will show you how to package them in
> +the exploded directory format for easy deployment. First you'll look at the
> +services.xml file that defines the Web service, and then you'll build the
> +files using <a href="http://ant.apache.org/">Apache Ant</a>, and deploy the
> +Web service on Tomcat.</p>
> +<a name="definingservice"></a>
> +
> +<h3>Defining the Service: services.xml</h3>
> +
> +<p>Before Axis2 can understand what is going on, you have to tell it to use
> +the services.xml file. Let's get right into it (see Code Listing 3).</p>
> +
> +<p><b>Code Listing 3: The service definition file: services.xml</b></p>
> +<pre>&lt;service name="WeatherService" scope="application"&gt;
> +    &lt;description&gt;
> +        Weather POJO Service
> +    &lt;/description&gt;
> +    &lt;messageReceivers&gt;
> +        &lt;messageReceiver
> +            mep="http://www.w3.org/2004/08/wsdl/in-only"
> +    class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/&gt;
> +        &lt;messageReceiver
> +            mep="http://www.w3.org/2004/08/wsdl/in-out"
> +    class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/&gt;
> +    &lt;/messageReceivers&gt;
> +    &lt;parameter name="ServiceClass" locked="false"&gt;
> +        sample.pojo.service.WeatherService
> +    &lt;/parameter&gt;
> +&lt;/service&gt;</pre>
> +
> +<p>The name of the service is specified as WeatherService and the scope of
> +the service is application. As you can see in the
> +WeatherService POJO, there are two methods, an IN-ONLY method and a IN-OUT
> +method, hence the ordering for the messageReceiver elements within the
> +messageReceivers tag. Lastly, the ServiceClass parameter specifies the class
> +of the Web service, which is sample.pojo.service.WeatherService. When
> +operations of your Web service get called, the methods of the WeatherService
> +class will be called. Next you'll take a look at an easy method of building
> +your application using Ant.</p>
> +<a name="buildpojows"></a>
> +
> +<h2>Building the POJO Web Service Using Apache Ant</h2>
> +
> +<p><a href="http://ant.apache.org/">Ant</a> is a slick build tool. It helps
> +reduce time to build applications, and several of the Axis2 command-line
> +tools create build.xml files for you, so that's why we'll use it here. We
> +won't go into the build.xml file that you'll be using in too much detail, so
> +here are the main Ant tasks you'll be using:</p>
> +<ul>
> +  <li>generate.service -- This Ant task builds all the service relevant
> +    source and copies the files to build/WeatherService</li>
> +  <li>rpc.client -- This task builds the client relevant files, builds a JAR
> +    at <em>build/lib/rpc-client.jar</em>, and then runs the client</li>
> +</ul>
> +
> +<p>Before you can build the source, however, you'll need to download the
> +Axis2 1.1-bin and 1.1-war distributions <a
> +href="../../download/1_1/download.html">here</a>. Then modify the following
> +line inside the build.xml file (in the axis2POJO directory of the <a
> +href="src/">source code</a> for this document) :</p>
> +<pre>&lt;property name="axis2.home" value="c:\apps\axis2" /&gt;</pre>
> +
> +<p>This modification contains the path to the root of the unzipped Axis2
> +1.1-bin <a href="../../download/1_1/download.html#std-bin">download</a>. With
> +that explanation, you'll now build the source by typing the following: ant</p>
> +
> +<p>The following directory format should now exist at
> +build/WeatherService:</p>
> +<pre> - WeatherService
> +   - META-INF
> +     - services.xml
> +   - sample
> +     - pojo
> +       - data
> +         - Weather.class
> +       - service
> +         - WeatherService.class</pre>
> +
> +<p>Simple isn't it? An excellent way to dive into Web services
> +development.</p>
> +
> +<p>Now get a <a href="http://tomcat.apache.org/">Tomcat</a> distribution (I
> +used v5.5), and start it up by running <em>bin/startup.bat</em> or
> +<em>bin/startup.sh</em>. Once it's running, deploy the Axis2 1.1-war by
> +copying the axis2.war file to Tomcat's webapps directory. Tomcat will proceed
> +by deploying axis2 and un-archive it into the webapps directory. Now copy the
> +WeatherService directory created when building our project to:
> +<em>&lt;tomcat-home&gt;/webapps/axis2/WEB-INF/services</em>.</p>
> +
> +<p>The service should quickly deploy, and you'll test the Web service using
> +the RPCServiceClient in the next section.</p>
> +<a name="testingpojows"></a>
> +
> +<h2>Testing the POJO Web Service Using RPCServiceClient</h2>
> +
> +<p>OK, so the Web service should be running on Tomcat. Now you'll build a
> +simple RPCServiceClient and test the POJO Web service. You'll first start out
> +with the class constructs, creating the RPCServiceClient and initializing the
> +values of the Weather class within the Web service (See Code Listing 4).</p>
> +
> +<p><b>Code Listing 4: Setting the weather</b></p>
> +<pre>package sample.pojo.rpcclient;
> +
> +import javax.xml.namespace.QName;
> +
> +import org.apache.axis2.AxisFault;
> +import org.apache.axis2.addressing.EndpointReference;
> +import org.apache.axis2.client.Options;
> +import org.apache.axis2.rpc.client.RPCServiceClient;
> +
> +import sample.pojo.data.Weather;
> +
> +
> +public class WeatherRPCClient {
> +
> +    public static void main(String[] args1) throws AxisFault {
> +
> +        RPCServiceClient serviceClient = new RPCServiceClient();
> +
> +        Options options = serviceClient.getOptions();
> +
> +        EndpointReference targetEPR = new EndpointReference(
> +                <b>"http://localhost:8080/axis2/services/WeatherService");</b>
> +        options.setTo(targetEPR);
> +
> +        // Setting the weather
> +        QName opSetWeather =
> +            new QName("http://service.pojo.sample/xsd", "<b>setWeather");
> +
> +        Weather w = new Weather();
> +
> +        w.setTemperature((float)39.3);
> +        w.setForecast("Cloudy with showers");
> +        w.setRain(true);
> +        w.setHowMuchRain((float)4.5);
> +
> +        Object[] opSetWeatherArgs = new Object[] { w };
> +
> +        serviceClient.invokeRobust(opSetWeather, opSetWeatherArgs);</b>
> +...</pre>
> +
> +<p>The most interesting code to note is in bold font. Notice the targetEPR
> +variable you create, setting the endpoint reference to
> +http://localhost:8080/axis2/services/WeatherService. This is where you
> +deployed it on Axis2. You can also verify this by asking Axis2 to list its
> +services by going to the following URL:
> +http://localhost:8080/axis2/services/listServices.</p>
> +
> +<p>Next the opSetWeather variable gets setup, pointing to the setWeather
> +operation. Then the Weather data gets created and initialized. Lastly, you
> +invoke the Web service, which initializes the weather data (you'll verify
> +this soon). Next you get back the weather data (see Code Listing 5).</p>
> +
> +<p><b>Code Listing 5: Getting the weather data</b></p>
> +<pre>...
> +        serviceClient.invokeRobust(opSetWeather, opSetWeatherArgs);
> +
> +        // Getting the weather
> +        QName opGetWeather =
> +            new QName("http://service.pojo.sample/xsd", "<b>getWeather");
> +
> +        Object[] opGetWeatherArgs = new Object[] { };
> +        Class[] returnTypes = new Class[] { Weather.class };
> +
> +        Object[] response = serviceClient.invokeBlocking(opGetWeather,
> +                opGetWeatherArgs, returnTypes);
> +
> +        Weather result = (Weather) response[0];
> +
> +        if (result == null) {
> +            System.out.println("Weather didn't initialize!");
> +            return;
> +        }</b>
> +...</pre>
> +
> +<p>First you set the operation in opGetWeather to getWeather. Then you create
> +an empty argument list. Note this time you expect something back from the Web
> +service, and so you create a list of return types. Then you invoke the Web
> +service using a blocking call and wait for the weather data to be returned to
> +you, and you place it in the result variable. Lastly, you make sure it isn't
> +null and that it was successfully initialized by the previous call to
> +setWeather. Now display the data to verify that it is indeed what you set it
> +to (see Code Listing 6).</p>
> +
> +<p><b>Code Listing 6: Displaying the data</b></p>
> +<pre>...
> +            return;
> +        }
> +
> +        // Displaying the result
> +        <b>System.out.println("Temperature               : " +
> +                           result.getTemperature());
> +        System.out.println("Forecast                  : " +
> +                           result.getForecast());
> +        System.out.println("Rain                      : " +
> +                           result.getRain());
> +        System.out.println("How much rain (in inches) : " +
> +                           result.getHowMuchRain());
> +
> +    }</b>
> +}</pre>
> +
> +<p>You should receive the data shown in Code Listing 7.</p>
> +
> +<p><b>Code Listing 7: Output from running the client</b></p>
> +<pre>rpc.client.run:
> +     [java] Temperature               : 39.3
> +     [java] Forecast                  : Cloudy with showers
> +     [java] Rain                      : true
> +     [java] How much rain (in inches) : 4.5</pre>
> +
> +<p>Excellent, you have a working POJO Web service! Next you'll quickly morph
> +this one into a Spring based POJO.</p>
> +<a name="limitationspojo"></a>
> +
> +<h3>Limitations and Strengths of POJO</h3>
> +
> +<p>We've covered the strengths of using POJO based Web services, but what
> +about any limitations? One main limitation of POJO based Web services is the
> +lack of initialization support (meaning that you have to go into your Web
> +service and initialize the values before the Web service is completely
> +useful), but you'll soon see how to overcome that limitation with a Spring
> +based POJO, covered next.</p>
> +<a name="springpojows"></a>
> +
> +<h2>Spring-based POJO Web Service</h2>
> +
> +<p>Spring is a hot framework for J2EE and makes bean usage a breeze. You'll
> +use it in this section to create a Spring based POJO Web service. For this
> +section you'll need the spring.jar from the latest 1.x Spring download.</p>
> +<a name="quickintro"></a>
> +
> +<h3>Quick Introduction</h3>
> +
> +<p>If you take a look at the <a href="src/">source code</a> of
> +this document (to see how the Spring based POJO Web service is coded), you
> +can see that the Weather class didn't change at all and the WeatherService
> +class only got its name changed to WeatherSpringService.</p>
> +
> +<p>You'll also notice an applicationContext.xml file, which we'll cover
> +later: it's used to setup the beans used in our Web service.</p>
> +
> +<p>Now you might wonder what the SpringInit.java class is for: This service
> +is necessary, however, to initialize the Spring Framework's application
> +context.</p>
> +
> +<p>The client is pretty much the same, except you won't use it to initialize
> +the Weather data in the Web service, since Spring does that for you using
> +Inversion of Control (IoC), which is covered next.</p>
> +<a name="servicedef"></a>
> +
> +<h3>The Service Definition: services.xml</h3>
> +
> +<p>Because the core POJOs didn't change, you'll move straight to the
> +services.xml file. It's a bit longer this time because it instantiates two
> +services in one file (see Code Listing 7).</p>
> +
> +<p><b>Code Listing 7: Defining the services: services.xml</b></p>
> +<pre>&lt;serviceGroup&gt;
> +  &lt;service <b>name="SpringInit"
> +class="sample.spring.service.SpringInit</b>"&gt;
> +    &lt;description&gt;
> +      This web service initializes Spring.
> +    &lt;/description&gt;
> +    <b>&lt;parameter name="ServiceClass" locked="false"&gt;
> +        sample.spring.service.SpringInit
> +    &lt;/parameter&gt;
> +    &lt;parameter name="ServiceTCCL"
> +locked="false"&gt;composite&lt;/parameter&gt;
> +    &lt;parameter name="load-on-startup"
> +locked="false"&gt;true&lt;/parameter&gt;</b>
> +    &lt;operation name="springInit"&gt;
> +      &lt;messageReceiver
> +      class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/&gt;
> +    &lt;/operation&gt;
> +  &lt;/service&gt;
> +  &lt;service <b>name="WeatherSpringService</b>"&gt;
> +    &lt;description&gt;
> +      Weather Spring POJO Axis2 AAR deployment
> +    &lt;/description&gt;
> +    <b>&lt;parameter name="ServiceClass" locked="false"&gt;
> +        sample.spring.service.WeatherSpringService
> +    &lt;/parameter&gt;
> +    &lt;parameter name="ServiceObjectSupplier" locked="false"&gt;
> +org.apache.axis2.extensions.spring.receivers.SpringAppContextAwareObjectSupplier
> +    &lt;/parameter&gt;
> +    &lt;parameter name="SpringBeanName" locked="false"&gt;
> +        weatherSpringService
> +    &lt;/parameter&gt;</b>
> +    &lt;messageReceivers&gt;
> +      &lt;messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
> +      class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/&gt;
> +      &lt;messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
> +      class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/&gt;
> +    &lt;/messageReceivers&gt;
> +  &lt;/service&gt;
> +&lt;/serviceGroup&gt;</pre>
> +
> +<p>You'll see a few familiar items in the above listing, and several changes.
> +Once again, the items in bold are most important. The ServiceTCCL property
> +under the SpringInit service makes sure that the Spring class loader is used
> +for the Web service, allowing it to properly instantiate the Spring
> +application context. The load-on-startup variable is a must-have so that the
> +service loads up immediately on startup, creating the Spring application
> +context. The WeatherSpringService stays mostly the same to the WeatherService
> +previously with a couple additions: The ServiceObjectSupplier provides the
> +service with the Spring application context, making it "Spring Aware." </p>
> +
> +<p>Lastly, the SpringBeanName points to the name of the bean associated with
> +this Web service, which is defined in the applicationContext.xml file
> +(essentially the WeatherSpringService). We'll cover the
> +applicationContext.xml file next. The application context:
> +applicationContext.xml file tells the Spring Framework, what beans are
> +defined. For this example, you'll define three of them (see Code Listing
> +8).</p>
> +
> +<p><b>Code Listing 8: Defining the application context:
> +applicationContext.xml</b></p>
> +<pre>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
> +&lt;!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
> +"http://www.springframework.org/dtd/spring-beans.dtd"&gt;
> +
> +&lt;beans&gt;
> +  &lt;bean id="<b>applicationContext</b>" class=
> +"org.apache.axis2.extensions.spring.receivers.ApplicationContextHolder" /&gt;
> +
> +  <b>&lt;bean id="weatherSpringService"
> +        class="sample.spring.service.WeatherSpringService"&gt;
> +    &lt;property name="weather" ref="weatherBean"/&gt;
> +  &lt;/bean&gt;
> +
> +  &lt;bean id="weatherBean" class="sample.spring.bean.Weather"&gt;
> +    &lt;property name="temperature" value="89.9"/&gt;
> +    &lt;property name="forecast" value="Sunny"/&gt;
> +    &lt;property name="rain" value="false"/&gt;
> +    &lt;property name="howMuchRain" value="0.2"/&gt;
> +  &lt;/bean&gt;</b>
> +&lt;/beans&gt;</pre>
> +
> +<p>The first one is Axis2's hook into Spring's application context (needed
> +since AAR deployment is quite different from regular WAR deployment). Next,
> +you define the bean pointed to by the services.xml file, the
> +weatherSpringService bean that points to the WeatherSpringService class. It
> +has one field property that gets initialized by the Spring Framework,
> +weather, which will be set to the weatherBean. The weatherBean is an
> +instantiation of the Weather class that holds information on the weather.
> +Spring will initialize it to the values shown above, and set the Weather
> +object in the WeatherSpringService class to this weatherBean instantiation.
> +Thus, when you deploy the Web service you won't have to instantiate the
> +values because they'll already be set.</p>
> +
> +<p>Next up is the SpringInit class.</p>
> +<a name="initializingspring"></a>
> +
> +<h3>Initializing the Spring application context: SpringInit</h3>
> +
> +<p>Without the Spring application context being initialized quickly, you'll
> +run into problems. The SpringInit class initializes the Spring application
> +context on startup because it is a ServiceLifeCycle class, whose startUp
> +method gets called upon loading the class (and because its load-on-startup
> +property is set in the serices.xml file). The only code worth mentioning in
> +this class is shown in Code Listing 9.</p>
> +
> +<p><b>Code Listing 9: SpringInit's startUp method</b></p>
> +<pre>    public void startUp(ConfigurationContext ignore,
> +                        AxisService service) {
> +        <b>ClassLoader classLoader = service.getClassLoader();
> +        ClassPathXmlApplicationContext appCtx = new
> +            ClassPathXmlApplicationContext</b>(new String[]
> +                                           {"<b>applicationContext.xml</b>"},
> +                                           false);
> +        <b>appCtx.setClassLoader(classLoader);
> +        appCtx.refresh();</b>
> +        if (logger.isDebugEnabled()) {
> +            logger.debug("\n\nstartUp() set spring classloader " +
> +                         "via axisService.getClassLoader() ... ");
> +        }
> +    }</pre>
> +
> +<p>Note that this method retrieves the Spring class loader, creates an
> +application context with applicationContext.xml as the parameters. This new
> +application context then gets the Spring class loader as its class loader.
> +The Spring Framework is now up and ready for our WeatherSpringService.</p>
> +
> +<h3>Build and Deploy Using Apache Axis2 and Tomcat</h3>
> +
> +<p>Great, your POJO is now ready for primetime within the Spring Framework.
> +Before you build, you'll first need to make sure the axis2-spring-1.1.jar and
> +spring.jar files are in the project's <em>src/lib</em> directory (the
> +axis2SpringPOJO directory found in the <a
> +href="src/axis2SpringPOJO/">source code</a> for this
> +document). Now build the source and create an AAR file by typing: ant</p>
> +
> +<p>It'll be created at <em>target/WeatherSpringService.aar</em>. Copy it over
> +to <em>&lt;tomcat-home&gt;/webapps/axis2/WEB-INF/services</em>, and Axis2
> +should deploy it quickly.</p>
> +
> +<p>Next test the Web service to see if Spring really will initialize the
> +weather data for you.</p>
> +<a name="testingrpc"></a>
> +
> +<h3>Testing Using an RPCServiceClient</h3>
> +
> +<p>It's as simple as it was for the other Web service, except this time type:
> +ant run.client</p>
> +
> +<p>Feel free to browse the code for this client in
> +src/client/WeatherSpringRPCClient.java. Essentially, this client does the
> +exact same thing as the client testing the WeatherService, except this one
> +skips the "Setting the weather" task since the weather data should already
> +have been set by the Spring framework at startup.</p>
> +
> +<p>Thus, you should get the following as output from the client:</p>
> +<pre>run.client:
> +    [javac] Compiling 1 source file to C:\apps\webapps\axis2SpringPOJO\target\cl
> +asses
> +     <b>[java] Temperature               : 89.9
> +     [java] Forecast                  : Sunny
> +     [java] Rain                      : false
> +     [java] How much rain (in inches) : 0.2</b></pre>
> +
> +<p>Which is exactly the values you set them to be in the
> +applicationContext.xml file!</p>
> +<a name="summary"></a>
> +
> +<h2>Summary</h2>
> +
> +<p>Apache Axis2 is an excellent way to expose your POJOs as Web services, and
> +Spring adds greater flexibility to your POJOs by adding beans support and
> +initialization abilities, along with all the other goodies provided by the
> +Spring framework.</p>
> +<a name="furtherstudy"></a>
> +
> +<h2>For Further Study</h2>
> +
> +<p>Apache Axis2-<a
> +href="http://ws.apache.org/axis2/">http://ws.apache.org/axis2/</a></p>
> +
> +<p>Axis2 Architecture-<a
> +href="http://ws.apache.org/axis2/1_0/Axis2ArchitectureGuide.html">http://ws.apache.org/axis2/1_0/Axis2ArchitectureGuide.html</a></p>
> +
> +<p>Introduction to Apache Axis2-<a
> +href="http://www.redhat.com/magazine/021jul06/features/apache_axis2/">http://www.redhat.com/magazine/021jul06/features/apache_axis2/</a></p>
> +
> +<p>Working With Apache Axis2-<a
> +href="http://www.wso2.net/articles/axis2/java/2006/09/13/working-with-axis2">http://www.wso2.net/articles/axis2/java/2006/09/13/working-with-axis2</a></p>
> +
> +<p>Apache Tomcat-<a
> +href="http://tomcat.apache.org/">http://tomcat.apache.org</a></p>
> +
> +<p>Spring Framework-<a
> +href="http://www.springframework.org/">http://www.springframework.org/</a></p>
> +</body>
> +</html>
>
> Added: webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2POJO/build.xml
> URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2POJO/build.xml?view=auto&rev=473184
> ==============================================================================
> --- webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2POJO/build.xml (added)
> +++ webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2POJO/build.xml Thu Nov  9 20:43:56 2006
> @@ -0,0 +1,73 @@
> +
> +<project basedir="." default="generate.service">
> +
> +       <property name="dest.dir" value="build" />
> +       <property name="dest.dir.classes" value="${dest.dir}/WeatherService" />
> +       <property name="dest.dir.lib" value="${dest.dir}/lib" />
> +       <property name="axis2.home" value="c:\apps\axis2" />
> +
> +       <path id="build.class.path">
> +               <fileset dir="${axis2.home}/lib">
> +                       <include name="*.jar" />
> +               </fileset>
> +       </path>
> +
> +       <path id="client.class.path">
> +               <fileset dir="${axis2.home}/lib">
> +                       <include name="*.jar" />
> +               </fileset>
> +               <fileset dir="${dest.dir.lib}">
> +                       <include name="*.jar" />
> +               </fileset>
> +
> +       </path>
> +       <target name="clean">
> +               <delete dir="${dest.dir}" />
> +               <delete dir="src" includes="sample/pojo/stub/**"/>
> +       </target>
> +
> +       <target name="prepare">
> +               <mkdir dir="${dest.dir}" />
> +               <mkdir dir="${dest.dir}/lib" />
> +               <mkdir dir="${dest.dir.classes}" />
> +               <mkdir dir="${dest.dir.classes}/META-INF" />
> +       </target>
> +
> +       <target name="generate.service" depends="clean,prepare">
> +
> +               <copy file="src/META-INF/services.xml" tofile="${dest.dir.classes}/META-INF/services.xml" overwrite="true" />
> +
> +               <javac srcdir="src" destdir="${dest.dir.classes}" includes="sample/pojo/service/**,sample/pojo/data/**">
> +                       <classpath refid="build.class.path" />
> +               </javac>
> +       </target>
> +
> +       <target name="rpc.client" depends="clean,prepare">
> +
> +               <antcall target="rpc.client.compile" />
> +
> +               <antcall target="rpc.client.jar" />
> +
> +               <antcall target="rpc.client.run">
> +                       <param name="uri" value="${uri}"/>
> +               </antcall>
> +
> +       </target>
> +
> +       <target name="rpc.client.compile">
> +               <javac srcdir="src" destdir="${dest.dir.classes}" includes="sample/pojo/rpcclient/**,sample/pojo/data/**">
> +                       <classpath refid="build.class.path" />
> +               </javac>
> +       </target>
> +
> +       <target name="rpc.client.jar">
> +               <jar basedir="${dest.dir.classes}" destfile="${dest.dir.lib}/rpc-client.jar" includes="sample/pojo/rpcclient/**,sample/pojo/data/**" />
> +       </target>
> +
> +       <target name="rpc.client.run">
> +               <java classname="sample.pojo.rpcclient.WeatherRPCClient">
> +                       <classpath refid="client.class.path" />
> +                       <arg value="${uri}" />
> +               </java>
> +       </target>
> +</project>
>
> Added: webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2POJO/src/META-INF/services.xml
> URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2POJO/src/META-INF/services.xml?view=auto&rev=473184
> ==============================================================================
> --- webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2POJO/src/META-INF/services.xml (added)
> +++ webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2POJO/src/META-INF/services.xml Thu Nov  9 20:43:56 2006
> @@ -0,0 +1,13 @@
> +<service name="WeatherService" scope="application">
> +    <description>
> +        Weather POJO Service
> +    </description>
> +    <messageReceivers>
> +        <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
> +                         class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
> +        <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
> +                         class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
> +    </messageReceivers>
> +    <parameter name="ServiceClass" locked="false">sample.pojo.service.WeatherService</parameter>
> +
> +</service>
>
> Added: webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2POJO/src/sample/pojo/data/Weather.java
> URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2POJO/src/sample/pojo/data/Weather.java?view=auto&rev=473184
> ==============================================================================
> --- webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2POJO/src/sample/pojo/data/Weather.java (added)
> +++ webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2POJO/src/sample/pojo/data/Weather.java Thu Nov  9 20:43:56 2006
> @@ -0,0 +1,40 @@
> +package sample.pojo.data;
> +
> +public class Weather{
> +    float temperature;
> +    String forecast;
> +    boolean rain;
> +    float howMuchRain;
> +
> +    public void setTemperature(float temp){
> +        temperature = temp;
> +    }
> +
> +    public float getTemperature(){
> +        return temperature;
> +    }
> +
> +    public void setForecast(String fore){
> +        forecast = fore;
> +    }
> +
> +    public String getForecast(){
> +        return forecast;
> +    }
> +
> +    public void setRain(boolean r){
> +        rain = r;
> +    }
> +
> +    public boolean getRain(){
> +        return rain;
> +    }
> +
> +    public void setHowMuchRain(float howMuch){
> +        howMuchRain = howMuch;
> +    }
> +
> +    public float getHowMuchRain(){
> +        return howMuchRain;
> +    }
> +}
> \ No newline at end of file
>
> Added: webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2POJO/src/sample/pojo/rpcclient/WeatherRPCClient.java
> URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2POJO/src/sample/pojo/rpcclient/WeatherRPCClient.java?view=auto&rev=473184
> ==============================================================================
> --- webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2POJO/src/sample/pojo/rpcclient/WeatherRPCClient.java (added)
> +++ webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2POJO/src/sample/pojo/rpcclient/WeatherRPCClient.java Thu Nov  9 20:43:56 2006
> @@ -0,0 +1,68 @@
> +package sample.pojo.rpcclient;
> +
> +import javax.xml.namespace.QName;
> +
> +import org.apache.axis2.AxisFault;
> +import org.apache.axis2.addressing.EndpointReference;
> +import org.apache.axis2.client.Options;
> +import org.apache.axis2.rpc.client.RPCServiceClient;
> +
> +import sample.pojo.data.Weather;
> +
> +
> +public class WeatherRPCClient {
> +
> +    public static void main(String[] args1) throws AxisFault {
> +
> +        RPCServiceClient serviceClient = new RPCServiceClient();
> +
> +        Options options = serviceClient.getOptions();
> +
> +        EndpointReference targetEPR = new EndpointReference(
> +                "http://localhost:8080/axis2/services/WeatherService");
> +        options.setTo(targetEPR);
> +
> +        // Setting the weather
> +        QName opSetWeather = new QName("http://service.pojo.sample/xsd", "setWeather");
> +
> +        Weather w = new Weather();
> +
> +        w.setTemperature((float)39.3);
> +        w.setForecast("Cloudy with showers");
> +        w.setRain(true);
> +        w.setHowMuchRain((float)4.5);
> +
> +        Object[] opSetWeatherArgs = new Object[] { w };
> +
> +        serviceClient.invokeRobust(opSetWeather, opSetWeatherArgs);
> +
> +
> +        // Getting the weather
> +        QName opGetWeather = new QName("http://service.pojo.sample/xsd", "getWeather");
> +
> +        Object[] opGetWeatherArgs = new Object[] { };
> +        Class[] returnTypes = new Class[] { Weather.class };
> +
> +
> +        Object[] response = serviceClient.invokeBlocking(opGetWeather,
> +                opGetWeatherArgs, returnTypes);
> +
> +        Weather result = (Weather) response[0];
> +
> +        if (result == null) {
> +            System.out.println("Weather didn't initialize!");
> +            return;
> +        }
> +
> +        // Displaying the result
> +        System.out.println("Temperature               : " +
> +                           result.getTemperature());
> +        System.out.println("Forecast                  : " +
> +                           result.getForecast());
> +        System.out.println("Rain                      : " +
> +                           result.getRain());
> +        System.out.println("How much rain (in inches) : " +
> +                           result.getHowMuchRain());
> +
> +    }
> +}
>
> Added: webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2POJO/src/sample/pojo/service/WeatherService.java
> URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2POJO/src/sample/pojo/service/WeatherService.java?view=auto&rev=473184
> ==============================================================================
> --- webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2POJO/src/sample/pojo/service/WeatherService.java (added)
> +++ webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2POJO/src/sample/pojo/service/WeatherService.java Thu Nov  9 20:43:56 2006
> @@ -0,0 +1,15 @@
> +package sample.pojo.service;
> +
> +import sample.pojo.data.Weather;
> +
> +public class WeatherService{
> +    Weather weather;
> +
> +    public void setWeather(Weather weather){
> +        this.weather = weather;
> +    }
> +
> +    public Weather getWeather(){
> +        return this.weather;
> +    }
> +}
> \ No newline at end of file
>
> Added: webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/build.xml
> URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/build.xml?view=auto&rev=473184
> ==============================================================================
> --- webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/build.xml (added)
> +++ webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/build.xml Thu Nov  9 20:43:56 2006
> @@ -0,0 +1,111 @@
> +<project basedir="." default="build" name="WeatherSpringService">
> +
> +    <property environment="env"/>
> +    <property name="service-name" value="WeatherSpringService.aar"/>
> +    <property name="dest.dir" value="target"/>
> +    <property name="axis2.home" value="c:\apps\axis2" />
> +
> +       <property name="repository.path" value="${axis2.home}/repository/services" />
> +
> +    <property name="dest.dir.classes" value="${dest.dir}/classes"/>
> +
> +    <property name="dest.dir.lib" value="${dest.dir}/lib"/>
> +    <property name="catalina-modules"
> +              value="${env.CATALINA_HOME}/webapps/axis2/WEB-INF/services"/>
> +
> +    <path id="build.class.path">
> +        <fileset dir="${axis2.home}/lib">
> +            <include name="*.jar"/>
> +        </fileset>
> +        <fileset dir="src/lib">
> +            <include name="*.jar"/>
> +        </fileset>
> +    </path>
> +
> +    <target name="clean">
> +        <delete dir="${dest.dir}"/>
> +    </target>
> +
> +    <target name="prepare" depends="clean">
> +
> +        <mkdir dir="${dest.dir}"/>
> +
> +        <mkdir dir="${dest.dir.classes}"/>
> +
> +        <mkdir dir="${dest.dir.classes}/META-INF"/>
> +
> +    </target>
> +
> +    <target name="build" depends="prepare">
> +
> +        <mkdir dir="${dest.dir}"/>
> +
> +        <mkdir dir="${dest.dir.classes}"/>
> +        <mkdir dir="${dest.dir.classes}/lib"/>
> +        <mkdir dir="${dest.dir.classes}/META-INF"/>
> +
> +        <copy file="src/applicationContext.xml"
> +              todir="${dest.dir.classes}"
> +              overwrite="true"/>
> +
> +        <copy file="src/META-INF/services.xml"
> +              tofile="${dest.dir.classes}/META-INF/services.xml"
> +              overwrite="true"/>
> +
> +        <copy todir="target/classes/lib">
> +          <fileset dir="src/lib"/>
> +        </copy>
> +
> +        <javac debug="on" srcdir="src" destdir="${dest.dir.classes}" includes="sample/**">
> +            <classpath refid="build.class.path"/>
> +        </javac>
> +
> +        <jar basedir="${dest.dir.classes}"
> +             destfile="${dest.dir}/${service-name}"/>
> +
> +    </target>
> +
> +     <target name="generate.service" depends="prepare">
> +
> +        <mkdir dir="${dest.dir}"/>
> +
> +        <mkdir dir="${dest.dir.classes}"/>
> +        <mkdir dir="${dest.dir.classes}/META-INF"/>
> +
> +        <copy file="src/META-INF/services.xml"
> +              tofile="${dest.dir.classes}/META-INF/services.xml"
> +              overwrite="true"/>
> +
> +        <javac debug="on" srcdir="src" destdir="${dest.dir.classes}" includes="sample/**">
> +            <classpath refid="build.class.path"/>
> +        </javac>
> +
> +        <jar basedir="${dest.dir.classes}"
> +             destfile="${repository.path}/${service-name}"/>
> +
> +    </target>
> +
> +
> +
> +    <target name="run.client" depends="prepare">
> +        <mkdir dir="${dest.dir}"/>
> +        <mkdir dir="${dest.dir.classes}"/>
> +
> +        <javac debug="on" srcdir="src" destdir="${dest.dir.classes}" includes="client/**">
> +            <classpath refid="build.class.path"/>
> +        </javac>
> +
> +        <java classname="client.WeatherSpringRPCClient">
> +            <classpath>
> +                <pathelement location="${dest.dir.classes}"/>
> +                <fileset dir="${axis2.home}/lib">
> +                    <include name="*.jar"/>
> +                </fileset>
> +            </classpath>
> +        </java>
> +       </target>
> +    <target name="copy.to.tomcat" depends="build">
> +        <copy file="${dest.dir}/${service-name}" todir="${catalina-modules}"/>
> +    </target>
> +
> +</project>
>
> Added: webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/META-INF/services.xml
> URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/META-INF/services.xml?view=auto&rev=473184
> ==============================================================================
> --- webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/META-INF/services.xml (added)
> +++ webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/META-INF/services.xml Thu Nov  9 20:43:56 2006
> @@ -0,0 +1,27 @@
> +<serviceGroup>
> +  <service name="SpringInit" class="sample.spring.service.SpringInit">
> +    <description>
> +      This web service initializes Spring.
> +    </description>
> +    <parameter name="ServiceClass" locked="false">sample.spring.service.SpringInit</parameter>
> +    <parameter name="ServiceTCCL" locked="false">composite</parameter>
> +    <parameter name="load-on-startup" locked="false">true</parameter>
> +    <operation name="springInit">
> +      <messageReceiver class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
> +    </operation>
> +  </service>
> +  <service name="WeatherSpringService">
> +    <description>
> +      Weather Spring POJO Axis2 AAR deployment
> +    </description>
> +    <parameter name="ServiceClass" locked="false">sample.spring.service.WeatherSpringService</parameter>
> +    <parameter name="ServiceObjectSupplier" locked="false">org.apache.axis2.extensions.spring.receivers.SpringAppContextAwareObjectSupplier</parameter>
> +    <parameter name="SpringBeanName" locked="false">weatherSpringService</parameter>
> +    <messageReceivers>
> +      <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
> +                       class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
> +      <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
> +                       class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
> +    </messageReceivers>
> +  </service>
> +</serviceGroup>
>
> Added: webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/applicationContext.xml
> URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/applicationContext.xml?view=auto&rev=473184
> ==============================================================================
> --- webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/applicationContext.xml (added)
> +++ webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/applicationContext.xml Thu Nov  9 20:43:56 2006
> @@ -0,0 +1,18 @@
> +<?xml version="1.0" encoding="UTF-8"?>
> +<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
> +
> +<beans>
> +  <bean id="applicationContext"
> +    class="org.apache.axis2.extensions.spring.receivers.ApplicationContextHolder" />
> +
> +  <bean id="weatherSpringService" class="sample.spring.service.WeatherSpringService">
> +    <property name="weather" ref="weatherBean"/>
> +  </bean>
> +
> +  <bean id="weatherBean" class="sample.spring.bean.Weather">
> +    <property name="temperature" value="89.9"/>
> +    <property name="forecast" value="Sunny"/>
> +    <property name="rain" value="false"/>
> +    <property name="howMuchRain" value="0.2"/>
> +  </bean>
> +</beans>
>
> Added: webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/client/WeatherSpringRPCClient.java
> URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/client/WeatherSpringRPCClient.java?view=auto&rev=473184
> ==============================================================================
> --- webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/client/WeatherSpringRPCClient.java (added)
> +++ webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/client/WeatherSpringRPCClient.java Thu Nov  9 20:43:56 2006
> @@ -0,0 +1,50 @@
> +package client;
> +
> +import javax.xml.namespace.QName;
> +
> +import org.apache.axis2.AxisFault;
> +import org.apache.axis2.addressing.EndpointReference;
> +import org.apache.axis2.client.Options;
> +import org.apache.axis2.rpc.client.RPCServiceClient;
> +
> +import sample.spring.bean.Weather;
> +
> +public class WeatherSpringRPCClient {
> +
> +    public static void main(String[] args1) throws AxisFault {
> +
> +        RPCServiceClient serviceClient = new RPCServiceClient();
> +
> +        Options options = serviceClient.getOptions();
> +
> +        EndpointReference targetEPR = new EndpointReference(
> +                "http://localhost:8080/axis2/services/WeatherSpringService");
> +        options.setTo(targetEPR);
> +
> +        // Get the weather (no setting, the Spring Framework has already initialized it for us)
> +        QName opGetWeather = new QName("http://service.spring.sample/xsd", "getWeather");
> +
> +        Object[] opGetWeatherArgs = new Object[] { };
> +        Class[] returnTypes = new Class[] { Weather.class };
> +
> +
> +        Object[] response = serviceClient.invokeBlocking(opGetWeather,
> +                opGetWeatherArgs, returnTypes);
> +
> +        Weather result = (Weather) response[0];
> +
> +        // display results
> +        if (result == null) {
> +            System.out.println("Weather didn't initialize!");
> +        }else{
> +            System.out.println("Temperature               : " +
> +                               result.getTemperature());
> +            System.out.println("Forecast                  : " +
> +                               result.getForecast());
> +            System.out.println("Rain                      : " +
> +                               result.getRain());
> +            System.out.println("How much rain (in inches) : " +
> +                               result.getHowMuchRain());
> +        }
> +    }
> +}
>
> Added: webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/sample/spring/bean/Weather.java
> URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/sample/spring/bean/Weather.java?view=auto&rev=473184
> ==============================================================================
> --- webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/sample/spring/bean/Weather.java (added)
> +++ webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/sample/spring/bean/Weather.java Thu Nov  9 20:43:56 2006
> @@ -0,0 +1,40 @@
> +package sample.spring.bean;
> +
> +public class Weather{
> +    float temperature;
> +    String forecast;
> +    boolean rain;
> +    float howMuchRain;
> +
> +    public void setTemperature(float temp){
> +        temperature = temp;
> +    }
> +
> +    public float getTemperature(){
> +        return temperature;
> +    }
> +
> +    public void setForecast(String fore){
> +        forecast = fore;
> +    }
> +
> +    public String getForecast(){
> +        return forecast;
> +    }
> +
> +    public void setRain(boolean r){
> +        rain = r;
> +    }
> +
> +    public boolean getRain(){
> +        return rain;
> +    }
> +
> +    public void setHowMuchRain(float howMuch){
> +        howMuchRain = howMuch;
> +    }
> +
> +    public float getHowMuchRain(){
> +        return howMuchRain;
> +    }
> +}
>
> Added: webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/sample/spring/service/SpringInit.java
> URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/sample/spring/service/SpringInit.java?view=auto&rev=473184
> ==============================================================================
> --- webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/sample/spring/service/SpringInit.java (added)
> +++ webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/sample/spring/service/SpringInit.java Thu Nov  9 20:43:56 2006
> @@ -0,0 +1,58 @@
> +package sample.spring.service;
> +
> +import org.apache.axiom.om.OMElement;
> +import org.apache.axis2.engine.ServiceLifeCycle;
> +import org.apache.axis2.context.ConfigurationContext;
> +import org.apache.axis2.context.OperationContext;
> +import org.apache.axis2.context.ServiceContext;
> +import org.apache.axis2.description.AxisService;
> +import org.springframework.context.support.ClassPathXmlApplicationContext;
> +
> +import org.apache.commons.logging.Log;
> +import org.apache.commons.logging.LogFactory;
> +
> +public class SpringInit implements ServiceLifeCycle {
> +
> +    private static Log logger = LogFactory
> +        .getLog(SpringInit .class);
> +
> +    // The web service
> +    public OMElement springInit(OMElement ignore) {
> +
> +        return null;
> +    }
> +
> +    public void init(ServiceContext serviceContext) {
> +
> +    }
> +
> +    public void setOperationContext(OperationContext arg0) {
> +
> +    }
> +
> +    public void destroy(ServiceContext arg0) {
> +
> +    }
> +
> +     /**
> +     * this will be called during the deployement time of the service. irrespective
> +     * of the service scope this method will be called
> +     */
> +    public void startUp(ConfigurationContext ignore, AxisService service) {
> +        ClassLoader classLoader = service.getClassLoader();
> +        ClassPathXmlApplicationContext appCtx = new
> +            ClassPathXmlApplicationContext(new String[] {"applicationContext.xml"}, false);
> +        appCtx.setClassLoader(classLoader);
> +        appCtx.refresh();
> +        if (logger.isDebugEnabled()) {
> +            logger.debug("\n\nstartUp() set spring classloader via axisService.getClassLoader() ... ");
> +        }
> +    }
> +    /**
> +     * this will be called during the deployement time of the service. irrespective
> +     * of the service scope this method will be called
> +     */
> +    public void shutDown(ConfigurationContext ignore, AxisService service) {
> +
> +    }
> +}
> \ No newline at end of file
>
> Added: webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/sample/spring/service/WeatherSpringService.java
> URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/sample/spring/service/WeatherSpringService.java?view=auto&rev=473184
> ==============================================================================
> --- webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/sample/spring/service/WeatherSpringService.java (added)
> +++ webservices/axis2/branches/java/1_1/xdocs/1_1/pojo/src/axis2SpringPOJO/src/sample/spring/service/WeatherSpringService.java Thu Nov  9 20:43:56 2006
> @@ -0,0 +1,15 @@
> +package sample.spring.service;
> +
> +import sample.spring.bean.Weather;
> +
> +public class WeatherSpringService{
> +    Weather weather;
> +
> +    public void setWeather(Weather w){
> +        weather = w;
> +    }
> +
> +    public Weather getWeather(){
> +        return weather;
> +    }
> +}
> \ No newline at end of file
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-cvs-help@ws.apache.org
>
>


-- 
Davanum Srinivas : http://www.wso2.net (Oxygen for Web Service Developers)

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Mime
View raw message