axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dee...@apache.org
Subject svn commit: r565295 [9/14] - in /webservices/axis2/site/1_3: ./ adb/ jibx/ src/
Date Mon, 13 Aug 2007 10:13:23 GMT
Added: webservices/axis2/site/1_3/pojoguide.html
URL: http://svn.apache.org/viewvc/webservices/axis2/site/1_3/pojoguide.html?view=auto&rev=565295
==============================================================================
--- webservices/axis2/site/1_3/pojoguide.html (added)
+++ webservices/axis2/site/1_3/pojoguide.html Mon Aug 13 03:13:18 2007
@@ -0,0 +1,879 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+
+
+
+
+
+
+
+
+<html>
+  <head>
+    <title>Apache Axis2 - </title>
+    <style type="text/css" media="all">
+      @import url("../css/maven-base.css");
+      @import url("../css/maven-theme.css");
+      @import url("../css/site.css");
+    </style>
+    <link rel="stylesheet" href="../css/print.css" type="text/css" media="print" />
+        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+      </head>
+  <body class="composite">
+    <div id="banner">
+                  <a href="../" id="bannerLeft">
+    
+                                    <img src="http://www.apache.org/images/asf_logo_wide.png" alt="" />
+    
+            </a>
+                          <span id="bannerRight">
+    
+                                    <img src="http://ws.apache.org/axis2/images/axis.jpg" alt="" />
+    
+            </span>
+            <div class="clear">
+        <hr/>
+      </div>
+    </div>
+    <div id="breadcrumbs">
+          
+  
+
+  
+    
+  
+  
+            <div class="xleft">
+        Last Published: 08/13/2007
+                      </div>
+            <div class="xright">      <a href="../index.html">Axis2/Java</a>
+          |
+          <a href="http://ws.apache.org/axis2/c">Axis2/C</a>
+          |
+          <a href="../../../">Apache WS</a>
+          |
+          <a href="http://www.apache.org">Apache</a>
+          
+  
+
+  
+    
+  
+  
+  </div>
+      <div class="clear">
+        <hr/>
+      </div>
+    </div>
+    <div id="leftColumn">
+      <div id="navcolumn">
+           
+  
+
+  
+    
+  
+  
+                   <h5>Axis2/Java</h5>
+        <ul>
+              
+    <li class="none">
+              <a href="../index.html">Home</a>
+        </li>
+          </ul>
+          <h5>Downloads</h5>
+        <ul>
+              
+    <li class="none">
+              <a href="../download.cgi">Releases</a>
+        </li>
+              
+    <li class="none">
+              <a href="../modules/index.html">Modules</a>
+        </li>
+              
+    <li class="none">
+              <a href="../tools/index.html">Tools</a>
+        </li>
+          </ul>
+          <h5>Documentation</h5>
+        <ul>
+              
+          
+              
+      
+            
+      
+            
+      
+            
+      
+            
+      
+            
+      
+            
+      
+            
+      
+              
+        <li class="expanded">
+              <a href="../1_3/contents.html">Version 1.3</a>
+                <ul>
+                  
+    <li class="none">
+              <a href="../1_3/toc.html">Table of Contents</a>
+        </li>
+                  
+    <li class="none">
+              <a href="../1_3/installationguide.html">Installation Guide</a>
+        </li>
+                  
+    <li class="none">
+              <a href="../1_3/quickstartguide.html">QuickStart Guide</a>
+        </li>
+                  
+    <li class="none">
+              <a href="../1_3/userguide.html">User Guide</a>
+        </li>
+                  
+    <li class="none">
+              <a href="../1_3/pojoguide.html">POJO Guide</a>
+        </li>
+                  
+    <li class="none">
+              <a href="../1_3/spring.html">Spring Guide</a>
+        </li>
+                  
+    <li class="none">
+              <a href="../1_3/webadminguide.html">Web Administrator's Guide</a>
+        </li>
+                  
+    <li class="none">
+              <a href="../1_3/migration.html">Migration Guide (from Axis1)</a>
+        </li>
+              </ul>
+        </li>
+              
+    <li class="none">
+              <a href="../1_2/contents.html">Version 1.2</a>
+        </li>
+              
+    <li class="none">
+              <a href="../1_1_1/contents.html">Version 1.1.1</a>
+        </li>
+              
+    <li class="none">
+              <a href="../1_1/contents.html">Version 1.1</a>
+        </li>
+              
+    <li class="none">
+              <a href="../1_0/index.html">Version 1.0</a>
+        </li>
+              
+    <li class="none">
+              <a href="../0_95/index.html">Version 0.95</a>
+        </li>
+              
+    <li class="none">
+              <a href="../0_94/index.html">Version 0.94</a>
+        </li>
+              
+    <li class="none">
+              <a href="../0_93/index.html">Version 0.93</a>
+        </li>
+          </ul>
+          <h5>Resources</h5>
+        <ul>
+              
+    <li class="none">
+              <a href="../faq.html">FAQ</a>
+        </li>
+              
+    <li class="none">
+              <a href="../articles.html">Articles</a>
+        </li>
+              
+    <li class="none">
+              <a href="http://wiki.apache.org/ws/FrontPage/Axis2/">Wiki</a>
+        </li>
+              
+    <li class="none">
+              <a href="../refLib.html">Reference Library</a>
+        </li>
+              
+    <li class="none">
+              <a href="http://ws.apache.org/axis2/1_3/api/index.html">Online Java Docs</a>
+        </li>
+          </ul>
+          <h5>Get Involved</h5>
+        <ul>
+              
+    <li class="none">
+              <a href="../overview.html">Overview</a>
+        </li>
+              
+    <li class="none">
+              <a href="../svn.html">Checkout the Source</a>
+        </li>
+              
+    <li class="none">
+              <a href="../mail-lists.html">Mailing Lists</a>
+        </li>
+              
+    <li class="none">
+              <a href="../release-process.html">Release Process</a>
+        </li>
+              
+    <li class="none">
+              <a href="../guidelines.html">Developer Guidelines</a>
+        </li>
+              
+    <li class="none">
+              <a href="../siteHowTo.html">Build the Site</a>
+        </li>
+          </ul>
+          <h5>Project Information</h5>
+        <ul>
+              
+    <li class="none">
+              <a href="../team-list.html">Project Team</a>
+        </li>
+              
+    <li class="none">
+              <a href="../issue-tracking.html">Issue Tracking</a>
+        </li>
+              
+    <li class="none">
+              <a href="http://svn.apache.org/viewcvs.cgi/webservices/axis2/trunk/?root=Apache-SVN">Source Code</a>
+        </li>
+              
+    <li class="none">
+              <a href="../thanks.html">Acknowledgements</a>
+        </li>
+              
+    <li class="none">
+              <a href="http://www.apache.org/licenses/LICENSE-2.0.html">License</a>
+        </li>
+          </ul>
+                                       <a href="http://maven.apache.org/" title="Built by Maven" id="poweredBy">
+            <img alt="Built by Maven" src="../images/logos/maven-feather.png"></img>
+          </a>
+                       
+  
+
+  
+    
+  
+  
+        </div>
+    </div>
+    <div id="bodyColumn">
+      <div id="contentBox">
+        <html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+<head>
+<meta name="generator" content="HTML Tidy for Windows (vers 14 June 2007), see www.w3.org"></meta>
+<meta http-equiv="content-type" content=""></meta>
+POJO Web Services using Axis2
+<link href="../css/axis-docs.css" rel="stylesheet" type="text/css" media="all"></link>
+</head>
+
+<h1>POJO Web Services using Apache Axis2</h1>
+<p>Want a quick way to get a Web service up and running in no time?
+Then you should consider creating a Plain Old Java Object (POJO)
+that you can deploy using Apache Axis2 on Apache Tomcat. POJOs are
+fast to build and easy to maintain, which means 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 learn how to
+take a POJO based on the Spring Framework, and deploy that as an
+AAR packaged Web service on Tomcat.</p>
+<h2>Content</h2>
+<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>
+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 describes how to build a POJO-style Web
+service with Apache Axis2 and Tomcat. It is organized as
+follows:
+<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>
+The code for the document can be found at
+Axis2_HOME/samples/pojoguide and Axis2_HOME/samples/pojoguidespring
+once you extract the <a href="../../download/1_3/download.html#std-bin">Axis2
+Standard Distribution</a>. (It is better to get it now as it will
+help you to follow along.) Let's get started.
+<a name="pojo"></a>
+<h2>The POJO</h2>
+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).
+<b>Code Listing 1: The Weather POJO</b>
+<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>
+And here's the WeatherService class, shown in Code Listing
+2.
+<b>Code Listing 2: The WeatherService class</b>
+<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>
+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.
+<a name="pojows"></a>
+<h2>POJO Web Service Using Apache Axis2 and Tomcat</h2>
+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.
+<a name="definingservice"></a>
+<h3>Defining the Service: services.xml</h3>
+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).
+<b>Code Listing 3: The service definition file:
+services.xml</b>
+<pre>
+&lt;service name=&quot;WeatherService&quot; scope=&quot;application&quot;&gt;
+    &lt;description&gt;
+        Weather POJO Service
+    &lt;/description&gt;
+    &lt;messageReceivers&gt;
+        &lt;messageReceiver 
+            mep=&quot;http://www.w3.org/2004/08/wsdl/in-only&quot;
+    class=&quot;org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver&quot;/&gt;
+        &lt;messageReceiver
+            mep=&quot;http://www.w3.org/2004/08/wsdl/in-out&quot;
+    class=&quot;org.apache.axis2.rpc.receivers.RPCMessageReceiver&quot;/&gt;
+    &lt;/messageReceivers&gt;
+    &lt;parameter name=&quot;ServiceClass&quot;&gt;
+        sample.pojo.service.WeatherService
+    &lt;/parameter&gt;
+&lt;/service&gt;
+</pre>
+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: IN-ONLY method and
+IN-OUT method. Hence the messageReceiver elements are ordered
+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 let usl take a look at an easy method of building your
+application using Ant.
+<a name="buildpojows"></a>
+<h2>Building the POJO Web Service Using Apache Ant</h2>
+<a href="http://ant.apache.org/">Ant</a> is a slick build tool.
+It helps reduce the time to build the applications, and several of
+the Axis2 command-line tools create the build.xml files for you.
+(We will not be going into too much detail on the build.xml file
+that you'll be using.)
+Here are the main Ant tasks you'll be using:
+<ul>
+<li>generate.service -- This Ant task builds 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>
+Before you can build the source, you'll need to download the
+Axis2 1.3-bin and 1.3-war distributions
+from <a href="../../download/1_3/download.html">here</a>. Then
+modify the following line inside the build.xml file (in the
+Axis2_HOME/samples/pojoguide directory in the extracted Axis2
+1.3 Standard Binary (bin) Distribution) :
+<pre>
+&lt;property name=&quot;axis2.home&quot; value=&quot;c:\apps\axis2&quot; /&gt;
+</pre>
+This modification contains the path to the root of the unzipped
+Axis2 1.3-bin <a href="../../download/1_3/download.html#std-bin">download</a>.
+With that explanation, you'll now build the source by typing the
+following: ant
+The following directory format should now exist at
+build/WeatherService:
+<pre>
+ - WeatherService
+   - META-INF
+     - services.xml
+   - sample
+     - pojo
+       - data
+         - Weather.class
+       - service
+         - WeatherService.class
+</pre>
+Simple isn't it? An excellent way to dive into Web services
+development.
+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.3-war by copying the
+axis2.war file to Tomcat's webapps directory. Tomcat will proceed
+by deploying axis2 and un-archiving it into the webapps directory.
+Now copy the WeatherService directory that was created at the time
+of building our project to:
+<em>&lt;tomcat-home&gt;/webapps/axis2/WEB-INF/services</em>.
+The service should deploy quickly. You willl test the Web
+service using the RPCServiceClient in the next section.
+<a name="testingpojows"></a>
+<h2>Testing the POJO Web Service Using RPCServiceClient</h2>
+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).
+<b>Code Listing 4: Setting the weather</b>
+<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>&quot;http://localhost:8080/axis2/services/WeatherService&quot;);</b>
+        options.setTo(targetEPR);
+
+        // Setting the weather
+        QName opSetWeather =
+            new QName(&quot;http://service.pojo.sample/xsd&quot;, &quot;<b>setWeather&quot;);
+
+        Weather w = new Weather();
+
+        w.setTemperature((float)39.3);
+        w.setForecast(&quot;Cloudy with showers&quot;);
+        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 is 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(&quot;http://service.pojo.sample/xsd&quot;, &quot;<b>getWeather&quot;);
+
+        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(&quot;Weather didn't initialize!&quot;);
+            return;
+        }</b>
+...
+</pre>
+<p>First you set the operation in opGetWeather to getWeather. Then
+you create an empty argument list. Note that 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 it. (see Code Listing
+6).</p>
+<p><b>Code Listing 6: Displaying the data</b></p>
+<pre>
+...
+            return;
+        }
+
+        // Displaying the result
+        <b>System.out.println(&quot;Temperature               : &quot; +
+                           result.getTemperature());
+        System.out.println(&quot;Forecast                  : &quot; +
+                           result.getForecast());
+        System.out.println(&quot;Rain                      : &quot; +
+                           result.getRain());
+        System.out.println(&quot;How much rain (in inches) : &quot; +
+                           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). However, you'll soon
+see how to overcome that limitation with a Spring based POJO, which
+is 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 source code of this document in
+Axis2_HOME/samples/pojoguidespring (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 is 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 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>Since the core POJOs didn't change, you 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=&quot;SpringInit&quot; 
+class=&quot;sample.spring.service.SpringInit</b>&quot;&gt;
+    &lt;description&gt;
+      This web service initializes Spring.
+    &lt;/description&gt;
+    <b>&lt;parameter name=&quot;ServiceClass&quot;&gt;
+        sample.spring.service.SpringInit
+    &lt;/parameter&gt;
+    &lt;parameter name=&quot;ServiceTCCL&quot;&gt;composite&lt;/parameter&gt;
+    &lt;parameter name=&quot;load-on-startup&quot;&gt;true&lt;/parameter&gt;</b>
+    &lt;operation name=&quot;springInit&quot;&gt;
+      &lt;messageReceiver 
+      class=&quot;org.apache.axis2.receivers.RawXMLINOutMessageReceiver&quot;/&gt;
+    &lt;/operation&gt;
+  &lt;/service&gt;
+  &lt;service <b>name=&quot;WeatherSpringService</b>&quot;&gt;
+    &lt;description&gt;
+      Weather Spring POJO Axis2 AAR deployment
+    &lt;/description&gt;
+    <b>&lt;parameter name=&quot;ServiceClass&quot;&gt;
+        sample.spring.service.WeatherSpringService
+    &lt;/parameter&gt;
+    &lt;parameter name=&quot;ServiceObjectSupplier&quot;&gt;
+org.apache.axis2.extensions.spring.receivers.SpringAppContextAwareObjectSupplier
+    &lt;/parameter&gt;
+    &lt;parameter name=&quot;SpringBeanName&quot;&gt;
+        weatherSpringService
+    &lt;/parameter&gt;</b>
+    &lt;messageReceivers&gt;
+      &lt;messageReceiver mep=&quot;http://www.w3.org/2004/08/wsdl/in-only&quot;
+      class=&quot;org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver&quot;/&gt;
+      &lt;messageReceiver mep=&quot;http://www.w3.org/2004/08/wsdl/in-out&quot;
+      class=&quot;org.apache.axis2.rpc.receivers.RPCMessageReceiver&quot;/&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 similar to the WeatherService
+previously with a couple of additions: The ServiceObjectSupplier
+provides the service with the Spring application context, making it
+&quot;Spring Aware.&quot;</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=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
+&lt;!DOCTYPE beans PUBLIC &quot;-//SPRING//DTD BEAN//EN&quot; 
+&quot;http://www.springframework.org/dtd/spring-beans.dtd&quot;&gt;
+
+&lt;beans&gt;
+  &lt;bean id=&quot;<b>applicationContext</b>&quot; class=
+&quot;org.apache.axis2.extensions.spring.receivers.ApplicationContextHolder&quot; /&gt;
+
+  <b>&lt;bean id=&quot;weatherSpringService&quot; 
+        class=&quot;sample.spring.service.WeatherSpringService&quot;&gt;
+    &lt;property name=&quot;weather&quot; ref=&quot;weatherBean&quot;/&gt;
+  &lt;/bean&gt;
+
+  &lt;bean id=&quot;weatherBean&quot; class=&quot;sample.spring.bean.Weather&quot;&gt;
+    &lt;property name=&quot;temperature&quot; value=&quot;89.9&quot;/&gt;
+    &lt;property name=&quot;forecast&quot; value=&quot;Sunny&quot;/&gt;
+    &lt;property name=&quot;rain&quot; value=&quot;false&quot;/&gt;
+    &lt;property name=&quot;howMuchRain&quot; value=&quot;0.2&quot;/&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 to which the services.xml
+file points, which is the weatherSpringService bean that points to
+the WeatherSpringService class. It has one field property that gets
+initialized by the Spring Framework - weather. This 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 the 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 services.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[]
+                                           {&quot;<b>applicationContext.xml</b>&quot;}, 
+                                           false);
+        <b>appCtx.setClassLoader(classLoader);
+        appCtx.refresh();</b>
+        if (logger.isDebugEnabled()) {
+            logger.debug(&quot;\n\nstartUp() set spring classloader &quot; +
+                         &quot;via axisService.getClassLoader() ... &quot;);
+        }
+    }
+</pre>
+<p>Note that this method retrieves the Spring class loader, and
+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>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.3.jar and spring.jar files are in the
+project's <em>Axis2_HOME/lib</em> directory.</p>
+<p><strong>Note:</strong> The service will not deploy if you add
+the above .jar files to the service archive due to class loding
+issues.</p>
+<p>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 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 whether Spring will really
+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 rpc.client</p>
+<p>Feel free to browse the code for this client in
+src/client/WeatherSpringRPCClient.java. Essentially, this client
+does the same thing as the client testing the WeatherService.
+Except that this one skips the &quot;Setting the weather&quot; task since the
+weather data should have already 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:\axis2-1.3\samples\pojoguidespring\build\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 are exactly the values you set 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. 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>
+
+</html>
+      </div>
+    </div>
+    <div class="clear">
+      <hr/>
+    </div>
+    <div id="footer">
+      <div class="xright">&#169;  
+          2004-2007
+    
+          Apache Software Foundation
+          
+  
+
+  
+    
+  
+  
+  </div>
+      <div class="clear">
+        <hr/>
+      </div>
+    </div>
+  </body>
+</html>

Added: webservices/axis2/site/1_3/quickstartguide.html
URL: http://svn.apache.org/viewvc/webservices/axis2/site/1_3/quickstartguide.html?view=auto&rev=565295
==============================================================================
--- webservices/axis2/site/1_3/quickstartguide.html (added)
+++ webservices/axis2/site/1_3/quickstartguide.html Mon Aug 13 03:13:18 2007
@@ -0,0 +1,1361 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+
+
+
+
+
+
+
+
+<html>
+  <head>
+    <title>Apache Axis2 - </title>
+    <style type="text/css" media="all">
+      @import url("../css/maven-base.css");
+      @import url("../css/maven-theme.css");
+      @import url("../css/site.css");
+    </style>
+    <link rel="stylesheet" href="../css/print.css" type="text/css" media="print" />
+        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+      </head>
+  <body class="composite">
+    <div id="banner">
+                  <a href="../" id="bannerLeft">
+    
+                                    <img src="http://www.apache.org/images/asf_logo_wide.png" alt="" />
+    
+            </a>
+                          <span id="bannerRight">
+    
+                                    <img src="http://ws.apache.org/axis2/images/axis.jpg" alt="" />
+    
+            </span>
+            <div class="clear">
+        <hr/>
+      </div>
+    </div>
+    <div id="breadcrumbs">
+          
+  
+
+  
+    
+  
+  
+            <div class="xleft">
+        Last Published: 08/13/2007
+                      </div>
+            <div class="xright">      <a href="../index.html">Axis2/Java</a>
+          |
+          <a href="http://ws.apache.org/axis2/c">Axis2/C</a>
+          |
+          <a href="../../../">Apache WS</a>
+          |
+          <a href="http://www.apache.org">Apache</a>
+          
+  
+
+  
+    
+  
+  
+  </div>
+      <div class="clear">
+        <hr/>
+      </div>
+    </div>
+    <div id="leftColumn">
+      <div id="navcolumn">
+           
+  
+
+  
+    
+  
+  
+                   <h5>Axis2/Java</h5>
+        <ul>
+              
+    <li class="none">
+              <a href="../index.html">Home</a>
+        </li>
+          </ul>
+          <h5>Downloads</h5>
+        <ul>
+              
+    <li class="none">
+              <a href="../download.cgi">Releases</a>
+        </li>
+              
+    <li class="none">
+              <a href="../modules/index.html">Modules</a>
+        </li>
+              
+    <li class="none">
+              <a href="../tools/index.html">Tools</a>
+        </li>
+          </ul>
+          <h5>Documentation</h5>
+        <ul>
+              
+          
+              
+      
+            
+      
+            
+      
+            
+      
+            
+      
+            
+      
+            
+      
+            
+      
+              
+        <li class="expanded">
+              <a href="../1_3/contents.html">Version 1.3</a>
+                <ul>
+                  
+    <li class="none">
+              <a href="../1_3/toc.html">Table of Contents</a>
+        </li>
+                  
+    <li class="none">
+              <a href="../1_3/installationguide.html">Installation Guide</a>
+        </li>
+                  
+    <li class="none">
+              <a href="../1_3/quickstartguide.html">QuickStart Guide</a>
+        </li>
+                  
+    <li class="none">
+              <a href="../1_3/userguide.html">User Guide</a>
+        </li>
+                  
+    <li class="none">
+              <a href="../1_3/pojoguide.html">POJO Guide</a>
+        </li>
+                  
+    <li class="none">
+              <a href="../1_3/spring.html">Spring Guide</a>
+        </li>
+                  
+    <li class="none">
+              <a href="../1_3/webadminguide.html">Web Administrator's Guide</a>
+        </li>
+                  
+    <li class="none">
+              <a href="../1_3/migration.html">Migration Guide (from Axis1)</a>
+        </li>
+              </ul>
+        </li>
+              
+    <li class="none">
+              <a href="../1_2/contents.html">Version 1.2</a>
+        </li>
+              
+    <li class="none">
+              <a href="../1_1_1/contents.html">Version 1.1.1</a>
+        </li>
+              
+    <li class="none">
+              <a href="../1_1/contents.html">Version 1.1</a>
+        </li>
+              
+    <li class="none">
+              <a href="../1_0/index.html">Version 1.0</a>
+        </li>
+              
+    <li class="none">
+              <a href="../0_95/index.html">Version 0.95</a>
+        </li>
+              
+    <li class="none">
+              <a href="../0_94/index.html">Version 0.94</a>
+        </li>
+              
+    <li class="none">
+              <a href="../0_93/index.html">Version 0.93</a>
+        </li>
+          </ul>
+          <h5>Resources</h5>
+        <ul>
+              
+    <li class="none">
+              <a href="../faq.html">FAQ</a>
+        </li>
+              
+    <li class="none">
+              <a href="../articles.html">Articles</a>
+        </li>
+              
+    <li class="none">
+              <a href="http://wiki.apache.org/ws/FrontPage/Axis2/">Wiki</a>
+        </li>
+              
+    <li class="none">
+              <a href="../refLib.html">Reference Library</a>
+        </li>
+              
+    <li class="none">
+              <a href="http://ws.apache.org/axis2/1_3/api/index.html">Online Java Docs</a>
+        </li>
+          </ul>
+          <h5>Get Involved</h5>
+        <ul>
+              
+    <li class="none">
+              <a href="../overview.html">Overview</a>
+        </li>
+              
+    <li class="none">
+              <a href="../svn.html">Checkout the Source</a>
+        </li>
+              
+    <li class="none">
+              <a href="../mail-lists.html">Mailing Lists</a>
+        </li>
+              
+    <li class="none">
+              <a href="../release-process.html">Release Process</a>
+        </li>
+              
+    <li class="none">
+              <a href="../guidelines.html">Developer Guidelines</a>
+        </li>
+              
+    <li class="none">
+              <a href="../siteHowTo.html">Build the Site</a>
+        </li>
+          </ul>
+          <h5>Project Information</h5>
+        <ul>
+              
+    <li class="none">
+              <a href="../team-list.html">Project Team</a>
+        </li>
+              
+    <li class="none">
+              <a href="../issue-tracking.html">Issue Tracking</a>
+        </li>
+              
+    <li class="none">
+              <a href="http://svn.apache.org/viewcvs.cgi/webservices/axis2/trunk/?root=Apache-SVN">Source Code</a>
+        </li>
+              
+    <li class="none">
+              <a href="../thanks.html">Acknowledgements</a>
+        </li>
+              
+    <li class="none">
+              <a href="http://www.apache.org/licenses/LICENSE-2.0.html">License</a>
+        </li>
+          </ul>
+                                       <a href="http://maven.apache.org/" title="Built by Maven" id="poweredBy">
+            <img alt="Built by Maven" src="../images/logos/maven-feather.png"></img>
+          </a>
+                       
+  
+
+  
+    
+  
+  
+        </div>
+    </div>
+    <div id="bodyColumn">
+      <div id="contentBox">
+        <html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta name="generator" content="HTML Tidy for Windows (vers 14 June 2007), see www.w3.org"></meta>
+<meta http-equiv="content-type" content="application/xhtml+xml; charset=us-ascii"></meta>
+Axis2 Quick Start Guide
+<link href="../css/axis-docs.css" rel="stylesheet" type="text/css" media="all"></link>
+</head>
+
+<h1>Axis2 Quick Start Guide</h1>
+<p>The purpose of this guide is to get you started on creating
+services and clients using Axis2 as quickly as possible. We'll take
+a simple StockQuote Service and show you some of the different ways
+in which you can create and deploy it, as well as take a quick look
+at one or two utilities that come with Axis2. We'll then look at
+creating clients to access those services.</p>
+<h2>Content</h2>
+<ul>
+<li><a href="#introduction">Introduction</a></li>
+<li><a href="#ready">Getting Ready</a></li>
+<li><a href="#services">Axis2 services</a></li>
+<li><a href="#create">Creating services</a>
+<ul>
+<li><a href="#deploy">Deploying POJOs</a></li>
+<li><a href="#axiom">Building the service using AXIOM</a></li>
+<li><a href="#adb">Generating the service using ADB</a></li>
+<li><a href="#xmlbeans">Generating the service using
+XMLBeans</a></li>
+<li><a href="#jibx">Generating the service using JiBX</a></li>
+</ul>
+</li>
+<li><a href="#clients">Generating Clients</a>
+<ul>
+<li><a href="#clientaxiom">Creating a client using AXIOM</a></li>
+<li><a href="#clientadb">Generating a client using ADB</a></li>
+<li><a href="#clientxmlbeans">Generating a client using XML
+Beans</a></li>
+<li><a href="#clientjibx">Generating a client using JiBX</a></li>
+</ul>
+</li>
+<li><a href="#summary">Summary</a></li>
+<li><a href="#furtherstudy">For Further Study</a></li>
+</ul>
+<h3>A Quick Setup Note:</h3>
+The code for the document can be found in the extracted <a href="../download/1_3/download.html#std-bin">Standard
+Binary Distribution</a>, more specifically at Axis2_HOME/samples/
+inside the directories- quickstart, quickstartadb, quickstartaxiom,
+quickstartjibx and quickstartxmlbeans. (Consider getting it now as
+it will help you to follow along.) It includes Ant buildfiles
+(build.xml) that we'll refer to throughout the examples to make
+compilation easier.
+<a name="introduction"></a>
+<h2>Introduction</h2>
+Let's start with the service itself. We'll make it simple so you
+can see what is going on when we build and deploy the services. A
+StockQuoteService example seems to be mandatory in instances like
+this one, so let's use the following (see Code Listing 1).
+<b>Code Listing 1: The StockQuoteService class</b>
+<pre>
+package samples.quickstart.service.pojo;
+
+import java.util.HashMap;
+
+public class StockQuoteService {
+    private HashMap map = new HashMap();
+
+    public double getPrice(String symbol) {
+        Double price = (Double) map.get(symbol);
+        if(price != null){
+            return price.doubleValue();
+        }
+        return 42.00;
+    }
+
+    public void update(String symbol, double price) {
+        map.put(symbol, new Double(price));
+    }
+}
+</pre>
+It will be a simple service with two possible calls. One of
+which is an in/out message, and the other is an in-only service.
+Ultimately, we'll package the service and deploy it in four
+different ways.
+First, let's look at how this simple Java class corresponds to a
+service.
+<a name="ready"></a>
+<h2>Getting Ready</h2>
+Before we build anything using Axis2, we have to take care of a
+little housekeeping. First off, you'll need to get your environment
+ready for working with Axis2. Fortunately, it involves just a few
+simple steps:
+<ol type="1">
+<li>Download and install Java (Minimum version is JDK1.4). Set the
+JAVA_HOME environment variable to the pathname of the directory
+into which you installed the JDK release.</li>
+<li>Download Axis2 and extract it to a target directory.</li>
+<li>Copy the axis2.war file to the webapps directory of your
+servlet engine.</li>
+<li>Set the AXIS2_HOME environment variable to point to the target
+directory in step. Note that all of the scripts and build files
+Axis2 generates depend on this value, so don't skip this step!
+Linux users can alternatively run the setenv.sh file in the
+AXIS2_HOME/bin directory to set the AXIS2_HOME environment variable
+to the pathname of the extracted directory of Axis2.</li>
+</ol>
+In most cases, we're also going to need a WSDL file for our
+service. Axis2's Java2WSDL can be used to bootstrap a WSDL. To
+generate a WSDL file from a Java class, perform the following
+steps:
+<ol type="1">
+<li>Create and compile the Java class.
+<pre>
+%AXIS2_HOME%/bin/java2wsdl -cp . -cn samples.quickstart.service.pojo.StockQuoteService -of StockQuoteService.wsdl
+</pre></li>
+<li>Generate the WSDL using the command:</li>
+</ol>
+Once you've generated the WSDL file, you can make the changes
+you need. For example, you might add custom faults or change the
+name of the generated elements. For example, this
+StockQuoteService.wsdl is in
+%AXIS2_HOME%/samples/quickstartadb/resources/META-INF folder, which
+we'll be using throughout the rest of this guide, replaces the
+generic parameters created by the generation process.
+<a name="services"></a>
+<h2>Axis2 Services</h2>
+Before we build anything, it's helpful to understand what the
+finished product looks like.
+The server side of Axis2 can be deployed on any Servlet engine,
+and has the following structure. Shown in Code Listing 2.
+<b>Code Listing 2: The Directory Structure of axis2.war</b>
+<pre>
+axis2-web 
+META-INF
+WEB-INF
+    classes 
+    conf
+        axis2.xml 
+    lib
+        activation.jar
+        ...
+        xmlSchema.jar
+    modules
+        modules.list 
+        addressing.mar
+        ...
+        soapmonitor.mar
+    services
+        services.list
+        aservice.aar
+        ...
+        version.aar
+    web.xml
+</pre>
+Starting at the top, axis2-web is a collection of JSPs that make
+up the Axis2 administration application, through which you can
+perform any action such as adding services and engaging and
+dis-engaging modules. The WEB-INF directory contains the actual
+java classes and other support files to run any services deployed
+to the services directory.
+The main file in all this is axis2.xml, which controls how the
+application deals with the received messages, determining whether
+Axis2 needs to apply any of the modules defined in the modules
+directory.
+Services can be deployed as *.aar files, as you can see here,
+but their contents must be arranged in a specific way. For example,
+the structure of this service will be as follows:
+<a name="aarstructure"></a>
+<pre>
+- StockQuoteService
+   - META-INF
+     - services.xml
+   - lib
+   - samples
+     - quickstart
+       - service
+         - pojo
+           - StockQuoteService.class
+</pre>
+Here, the name of the service is StockQuoteService, which is
+specified in the services.xml file and corresponds to the top-level
+folder of this service. Compiled Java classes are placed underneath
+this in their proper place based on the package name. The lib
+directory holds any service-specific JAR files needed for the
+service to run (none in this case) besides those already stored
+with the Axis2 WAR file and the servlet container's common JAR
+directories. Finally, the META-INF directory contains any
+additional information about the service that Axis2 needs to
+execute it properly. The services.xml file defines the service
+itself and links the Java class to it (See Code Listing 3).
+<b>Code Listing 3: The Service Definition File</b>
+<pre>
+&lt;service name=&quot;StockQuoteService&quot; scope=&quot;application&quot;&gt;
+    &lt;description&gt;
+        Stock Quote Sample Service
+    &lt;/description&gt;
+    &lt;messageReceivers&gt;
+        &lt;messageReceiver 
+            mep=&quot;http://www.w3.org/2004/08/wsdl/in-only&quot;
+    class=&quot;org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver&quot;/&gt;
+        &lt;messageReceiver
+            mep=&quot;http://www.w3.org/2004/08/wsdl/in-out&quot;
+    class=&quot;org.apache.axis2.rpc.receivers.RPCMessageReceiver&quot;/&gt;
+    &lt;/messageReceivers&gt;
+    &lt;parameter name=&quot;ServiceClass&quot;&gt;
+        samples.quickstart.service.pojo.StockQuoteService
+    &lt;/parameter&gt;
+&lt;/service&gt;
+</pre>
+Here the service is defined, along with the relevant
+messageReceiver types for the different message exchange
+patterns.
+The META-INF directory is also the location for any custom WSDL
+files you intend to include for this application.
+You can deploy a service by simply taking this hierarchy of
+files and copying it to the webapps/axis2/WEB-INF/services
+directory of your servlet engine. (Note the Axis2 WAR file must be
+installed first in the servlet engine.) This is known as the
+&quot;exploded&quot; format. You can also compress your documents into an
+*.aar file, similar to a *.jar file, and place the *.aar file
+directly in the servlet engine's webapps/axis2/WEB-INF/services
+directory.
+Now that you understand what we're trying to accomplish, we're
+almost ready to start building.
+First, <a href="../download/1_3/download.html#std-bin">download</a>
+and unzip the appropriate version of Axis2 Standard Binary
+Distribution. Make sure that you set the value of the AXIS2_HOME
+variable to match the location into which you extracted the
+contents of this release.
+Let's look at some different ways to create clients and
+services.
+<a name="create"></a>
+<h2>Creating Services</h2>
+<p>In this section, we'll look at five ways to create a service
+based on the StockQuoteService class: deploying Plain Old Java
+Objects (POJO), building the service using AXIOM's OMElement,
+generating the service using Axis2 Databinding Framework (ADB),
+generating the service using XMLBeans, and generating the service
+using JiBX.</p>
+<a name="deploy"></a>
+<h3>Deploying POJOs</h3>
+<p>To deploy the service using POJOs (Plain Old Java Objects),
+execute the following steps.</p>
+<p>Note the directory structure contained at
+&lt;AXIS2_HOME&gt;/samples/quickstart (the services.xml file is
+from the first section of this guide):</p>
+<pre>
+- quickstart
+   - README.txt
+   - build.xml
+   - resources
+     - META-INF
+       - services.xml
+   - src
+     - samples
+       - quickstart
+         - service
+           - pojo
+             - StockQuoteService.java
+</pre>
+<p>Note that you can generate a WSDL from the quickstart directory
+by typing:</p>
+<pre>
+ant generate.wsdl
+</pre>
+However, creating StockQuoteService.wsdl is optional. It can be the
+version generated directly from the Java class, or a customized
+version of that file, and that services.xml is the same file
+referenced earlier in this document.
+<p>Now build the project by typing ant generate.service in the
+quickstart directory, which creates the following directory
+structure:</p>
+<pre>
+- quickstart/build/classes
+   - META-INF
+     - services.xml
+   - samples
+     - quickstart
+       - service
+         - pojo
+           - StockQuoteService.class
+</pre>
+<p>If you want to deploy the service in an exploded directory
+format, rename the classes directory to StockQuoteService, and copy
+it to the webapps/axis2/WEB-INF/services directory in your servlet
+engine. Otherwise, copy the build/StockQuoteService.aar file to the
+webapps/axis2/WEB-INF/services directory in your servlet engine.
+Then check to make sure that the service has been properly deployed
+by viewing the list of services at:</p>
+<pre>
+http://localhost:8080/axis2/services/listServices
+</pre>
+<p>You can also checkout the WSDL at:</p>
+<pre>
+http://localhost:8080/axis2/services/StockQuoteService?wsdl
+</pre>
+<p>And the schema at:</p>
+<pre>
+http://localhost:8080/axis2/services/StockQuoteService?xsd
+</pre>
+<p>Once the URLs are working, quickly test the service. Try
+pointing your browser to the following URL:</p>
+<pre>
+http://localhost:8080/axis2/services/StockQuoteService/getPrice?symbol=IBM
+</pre>
+<p>You will get the following response:</p>
+<pre>
+&lt;ns:getPriceResponse xmlns:ns=&quot;http://pojo.service.quickstart.samples/xsd&quot;&gt;&lt;ns:return&gt;42&lt;/ns:return&gt;&lt;/ns:getPriceResponse&gt;
+</pre>
+<p>If you invoke the update method as,</p>
+<pre>
+http://localhost:8080/axis2/services/StockQuoteService/update?symbol=IBM&amp;price=100
+</pre>
+and then execute the first getPrice URL, you will see that the
+price has got updated. <a name="axiom"></a>
+<h3>Building the Service using AXIOM</h3>
+<p>To build a service &quot;from scratch&quot; using AXIOM, execute the
+following steps.</p>
+<p>Note the directory structure contained at
+/samples/quickstartaxiom:</p>
+<pre>
+- quickstartaxiom
+   - README.txt
+   - build.xml
+   - resources
+     - META-INF
+       - services.xml
+       - StockQuoteService.wsdl
+   - src
+     - samples
+       - quickstart
+         - service
+           - axiom
+             - StockQuoteService.java
+         - clients
+           - AXIOMClient.java
+</pre>
+<p>Since AXIOM is a little different, you're going to need a
+different services.xml file from the one used for POJO. Define it,
+as shown in Code Listing 4.</p>
+<p><b>Code Listing 4: The Service Definition File.</b></p>
+<pre>
+&lt;service name=&quot;StockQuoteService&quot; scope=&quot;application&quot;&gt;
+    &lt;description&gt;
+        Stock Quote Service
+    &lt;/description&gt;
+    &lt;operation name=&quot;getPrice&quot;&gt;
+        &lt;messageReceiver class=&quot;org.apache.axis2.receivers.RawXMLINOutMessageReceiver&quot;/&gt;
+    &lt;/operation&gt;
+    &lt;operation name=&quot;update&quot;&gt;
+        &lt;messageReceiver class=&quot;org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver&quot;/&gt;
+    &lt;/operation&gt;
+    &lt;parameter name=&quot;ServiceClass&quot;&gt;samples.quickstart.service.axiom.StockQuoteService&lt;/parameter&gt;
+&lt;/service&gt;
+</pre>
+<p>Note that it's almost the same, except that the operations are
+explicitly defined in the service.xml file, and the
+MessageReceivers are now RawXML.</p>
+<p>Now, the above referenced StockQuoteService.java class, a plain
+Java class that uses classes from the Axis2 libraries, is defined
+as shown in Code Listing 5.</p>
+<p><b>Code Listing 5: The StockQuoteService Class using
+AXIOM</b></p>
+<pre>
+package samples.quickstart.service.axiom;
+
+import javax.xml.stream.XMLStreamException;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+
+import java.util.HashMap;
+public class StockQuoteService {
+    private HashMap map = new HashMap();
+
+    public OMElement getPrice(OMElement element) throws XMLStreamException {
+        element.build();
+        element.detach();
+
+        OMElement symbolElement = element.getFirstElement();
+        String symbol = symbolElement.getText();
+
+        String returnText = &quot;42&quot;;
+        Double price = (Double) map.get(symbol);
+        if(price != null){
+            returnText  = &quot;&quot; + price.doubleValue();
+        }
+        OMFactory fac = OMAbstractFactory.getOMFactory();
+        OMNamespace omNs =
+            fac.createOMNamespace(&quot;http://axiom.service.quickstart.samples/xsd&quot;, &quot;tns&quot;);
+        OMElement method = fac.createOMElement(&quot;getPriceResponse&quot;, omNs);
+        OMElement value = fac.createOMElement(&quot;price&quot;, omNs);
+        value.addChild(fac.createOMText(value, returnText));
+        method.addChild(value);
+        return method;
+    }
+
+    public void update(OMElement element) throws XMLStreamException {
+        element.build();
+        element.detach();
+
+        OMElement symbolElement = element.getFirstElement();
+        String symbol = symbolElement.getText();
+
+        OMElement priceElement = (OMElement)symbolElement.getNextOMSibling();
+        String price = priceElement.getText();
+
+        map.put(symbol, new Double(price));
+    }
+}
+</pre>
+<p>Axis2 uses AXIOM, or the AXIs Object Model, a <a href="http://www.w3.org/DOM/">DOM</a> (Document Object Model)-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 that happens, in this
+case, to be the payload of the incoming SOAP message. Method
+getPrice(OMElement), for example, extracts the contents of the
+first child of the payload element, which corresponds to the stock
+symbol, and uses this to look up the current price of the stock.
+Unless this is an &quot;in only&quot; service, these methods must return an
+OMElement, because that becomes the payload of the return SOAP
+message.</p>
+<p>Now build the project by typing ant generate.service in the
+Axis2_HOME/samples/quickstartaxiom directory.</p>
+<p>Place the StockQuoteService.aar file in the
+webapps/axis2/WEB-INF/services directory of the servlet engine, and
+check to make sure that the service has been properly deployed by
+viewing the list of services at,</p>
+<pre>
+http://localhost:8080/axis2/services/listServices
+</pre>
+<p>You can also check the custom WSDL at,</p>
+<pre>
+http://localhost:8080/axis2/services/StockQuoteService?wsdl
+</pre>
+<p>and the schema at,</p>
+<pre>
+http://localhost:8080/axis2/services/StockQuoteService?xsd
+</pre>
+<a name="adb"></a>
+<h3>Generating the Service using ADB</h3>
+<p>To generate and deploy the service using the Axis2 Databinding
+Framework (ADB), execute the following steps.</p>
+<p>Generate the skeleton using the WSDL2Java utility by typing the
+following in the Axis2_HOME/samples/quickstartadb directory:</p>
+<pre>
+%AXIS2_HOME%/bin/WSDL2Java -uri resources/META-INF/StockQuoteService.wsdl -p samples.quickstart.service.adb -d adb -s -ss -sd -ssi -o build/service
+</pre>
+<p>Else, simply type ant generate.service in the
+Axis2_HOME/samples/quickstartadb directory.</p>
+<p>The option -d adb specifies Axis Data Binding (ADB). The -s
+switch specifies synchronous or blocking calls only. The -ss switch
+creates the server side code (skeleton and related files). The -sd
+switch creates a service descriptor (services.xml file). The -ssi
+switch creates an interface for the service skeleton. The service
+files should now be located at build/service.</p>
+<p>If you generated the code by using WSDL2Java directly, next you
+have to modify the generated skeleton to implement the service (if
+you used &quot;ant generate.service&quot;, a completed skeleton will be
+copied over the generated one automatically).</p>
+<p>Open the
+build/service/src/samples/quickstart/adb/service/StockQuoteServiceSkeleton.java
+file and modify it to add the functionality of your service to the
+generated methods; shown in Code Listing 6.</p>
+<p><b>Code Listing 6: Defining the Service Skeleton File</b></p>
+<pre>
+package samples.quickstart.service.adb;
+
+import samples.quickstart.service.adb.xsd.GetPriceResponse;
+import samples.quickstart.service.adb.xsd.Update;
+import samples.quickstart.service.adb.xsd.GetPrice;
+
+import java.util.HashMap;
+
+public class StockQuoteServiceSkeleton {
+
+    private static HashMap map;
+
+    static{ map = new HashMap(); }
+
+    public void update(Update param0) {
+        map.put(param0.getSymbol(), new Double(param0.getPrice()));
+    }
+
+    public GetPriceResponse getPrice(GetPrice param1) {
+        Double price = (Double) map.get(param1.getSymbol());
+        double ret = 42;
+        if(price != null){
+            ret = price.doubleValue();
+        }
+        GetPriceResponse res =
+                new GetPriceResponse();
+        res.set_return(ret);
+        return res;
+    }
+}
+</pre>
+<p>Now you can build the project by typing the following command in
+the build/service directory:</p>
+<pre>
+ant jar.server
+</pre>
+<p>If all goes well, you should see the BUILD SUCCESSFUL message in
+your window, and the StockQuoteService.aar file in the
+build/service/build/lib directory. Copy this file to the
+webapps/axis2/WEB-INF/services directory of the servlet engine.</p>
+<p>You can check to make sure that the service has been properly
+deployed by viewing the list of services at,</p>
+<pre>
+http://localhost:8080/axis2/services/listServices
+</pre>
+<p>You can also check the custom WSDL at,</p>
+<pre>
+http://localhost:8080/axis2/services/StockQuoteService?wsdl
+</pre>
+<p>and the schema at,</p>
+<pre>
+http://localhost:8080/axis2/services/StockQuoteService?xsd
+</pre>
+<a name="xmlbeans"></a>
+<h3>Generating the Service using XMLBeans</h3>
+<p>To generate a service using XMLBeans, execute the following
+steps.</p>
+<p>Generate the skeleton using the WSDL2Java utility by typing the
+following in the Axis2_HOME/samples/quickstartxmlbeans
+directory.</p>
+<pre>
+%AXIS2_HOME%/bin/WSDL2Java -uri resources/META-INF/StockQuoteService.wsdl -p samples.quickstart.service.xmlbeans -d xmlbeans -s -ss -sd -ssi -o build/service
+</pre>
+<p>Else simply type ant generate.service in the
+Axis2_HOME/samples/quickstartxmlbeans directory.</p>
+<p>The option -d xmlbeans specifies XML Beans data binding. The -s
+switch specifies synchronous or blocking calls only. The -ss switch
+creates the server side code (skeleton and related files). The -sd
+switch creates a service descriptor (services.xml file). The -ssi
+switch creates an interface for the service skeleton. The service
+files should now be located at build/service.</p>
+<p>If you generated the code by using WSDL2Java directly, next you
+have to modify the generated skeleton to implement the service (if
+you used &quot;ant generate.service&quot;, a completed skeleton will be
+copied over the generated one automatically).</p>
+<p>Next open the
+build/service/src/samples/quickstart/service/xmlbeans/StockQuoteServiceSkeleton.java
+file and modify it to add the functionality of your service to the
+generated methods (see Code Listing 7).</p>
+<p><b>Code Listing 7: Defining the Service Skeleton</b></p>
+<pre>
+package samples.quickstart.service.xmlbeans;
+
+import samples.quickstart.service.xmlbeans.xsd.GetPriceDocument;
+import samples.quickstart.service.xmlbeans.xsd.GetPriceResponseDocument;
+import samples.quickstart.service.xmlbeans.xsd.UpdateDocument;
+
+import java.util.HashMap;
+
+public class StockQuoteServiceSkeleton implements StockQuoteServiceSkeletonInterface {
+
+    private static HashMap map;
+
+    static{ map = new HashMap(); }
+
+    public void update(UpdateDocument param0) {
+        <b>map.put(param0.getUpdate().getSymbol(), new Double(param0.getUpdate().getPrice()));</b>
+    }
+
+    public GetPriceResponseDocument getPrice(GetPriceDocument param1) {
+        <b>Double price = (Double) map.get(param1.getGetPrice().getSymbol());
+        double ret = 42;
+        if(price != null){
+            ret = price.doubleValue();
+        }
+        System.err.println();
+        GetPriceResponseDocument resDoc =
+                GetPriceResponseDocument.Factory.newInstance();
+        GetPriceResponseDocument.GetPriceResponse res =
+                resDoc.addNewGetPriceResponse();
+        res.setReturn(ret);
+        return resDoc;</b>
+    }
+}
+</pre>
+<p>Build the project by typing the following command in the
+build/service directory, which contains the build.xml file:</p>
+<pre>
+ant jar.server
+</pre>
+<p>If all goes well, you should see the BUILD SUCCESSFUL message in
+your window, and the StockQuoteService.aar file in the newly
+created build/service/build/lib directory. Copy this file to the
+webapps/axis2/WEB-INF/services directory of the servlet engine.</p>
+<p>You can check to make sure that the service has been properly
+deployed by viewing the list of services at,</p>
+<pre>
+http://localhost:8080/axis2/services/listServices
+</pre>
+<p>You can also check the custom WSDL at,</p>
+<pre>
+http://localhost:8080/axis2/services/StockQuoteService?wsdl
+</pre>
+<p>and the schema at,</p>
+<pre>
+http://localhost:8080/axis2/services/StockQuoteService?xsd
+</pre>
+<a name="jibx"></a>
+<h3>Generating the Service using JiBX</h3>
+<p>To generate and deploy the service using <a href="http://www.jibx.org">JiBX data binding</a>, execute the following
+steps.</p>
+<p>Generate the skeleton using the WSDL2Java utility by typing the
+following at a console in the Axis2_HOME/samples/quickstartjibx
+directory:</p>
+<pre>
+%AXIS2_HOME%/bin/wsdl2java -uri resources/META-INF/StockQuoteService.wsdl -p samples.quickstart.service.jibx -d jibx -s -ss -sd -ssi -uw -o build/service
+</pre>
+<p>Else, simply type &quot;ant generate.service&quot; in the
+Axis2_HOME/samples/quickstartjibx directory.</p>
+<p>The option -d jibx specifies JiBX data binding. The -s switch
+specifies synchronous or blocking calls only. The -ss switch
+creates the server side code (skeleton and related files). The -sd
+switch creates a service descriptor (services.xml file). The -ssi
+switch creates an interface for the service skeleton. The -uw
+switch unwraps the parameters passed to and from the service
+operations in order to create a more natural programming
+interface.</p>
+<p>After running WSDL2Java, the service files should be located at
+build/service. If you generated the code by using WSDL2Java
+directly, you need to modify the generated skeleton to implement
+the service (if you used &quot;ant generate.service&quot; a completed
+skeleton will be copied over the generated one automatically). Open
+the
+build/service/src/samples/quickstart/service/jibx/StockQuoteServiceSkeleton.java
+file and modify it to add the functionality of your service to the
+generated methods, as shown in Code Listing 8.</p>
+<p><b>Code Listing 8: Defining the Service Skeleton File</b></p>
+<pre>
+package samples.quickstart.service.jibx;
+
+import java.util.HashMap;
+
+public class StockQuoteServiceSkeleton implements StockQuoteServiceSkeletonInterface {
+    private HashMap map = new HashMap();
+
+    public void update(String symbol, Double price) {
+        map.put(symbol, price);
+    }
+
+    public Double getPrice(String symbol) {
+        Double ret = (Double) map.get(symbol);
+        if (ret == null) {
+            ret = new Double(42.0);
+        }
+        return ret;
+    }
+}
+</pre>
+<p>Now you can build the project by typing the following command in
+the build/service directory:</p>
+<pre>
+ant jar.server
+</pre>
+<p>If all goes well, you should see the BUILD SUCCESSFUL message in
+your window, and the StockQuoteService.aar file in the
+build/service/build/lib directory. Copy this file to the
+webapps/axis2/WEB-INF/services directory of the servlet engine.</p>
+<p>You can check to make sure that the service has been properly
+deployed by viewing the list of services at,</p>
+<pre>
+http://localhost:8080/axis2/services/listServices
+</pre>
+<p>You can also check the custom WSDL at,</p>
+<pre>
+http://localhost:8080/axis2/services/StockQuoteService?wsdl
+</pre>
+<p>and the schema at,</p>
+<pre>
+http://localhost:8080/axis2/services/StockQuoteService?xsd
+</pre>
+<p>For more information on using JiBX with Axis2, see the <a href="jibx/jibx-codegen-integration.html">JiBX code generation
+integration</a> details. You can also check the <a href="http://www.sosnoski.com/jibx-wiki/space/axis2-jibx">JiBX Axis2
+Wiki page</a> for updated information about using JiBX with
+Axis2.</p>
+<a name="clients"></a>
+<h2>Creating Clients</h2>
+<p>In this section, we'll look at four ways to create clients based
+on the StockQuoteService class: building an AXIOM based client,
+generating a client using Axis2 Databinding Framework (ADB),
+generating a client using XMLBeans, and generating a client using
+JiBX.</p>
+<a name="clientaxiom"></a>
+<h3>Creating a Client with AXIOM</h3>
+<p>To build a client using AXIOM, execute the following steps.</p>
+<p>Also, note the directory structure shown in the Creating a
+service with AXIOM section, duplicated below for completeness.</p>
+<pre>
+- quickstartaxiom
+   - README.txt
+   - build.xml
+   - resources
+     - META-INF
+       - services.xml
+       - StockQuoteService.wsdl
+   - src
+     - samples
+       - quickstart
+         - service
+           - axiom
+             - StockQuoteService.java
+         - clients
+           - AXIOMClient.java
+</pre>
+<p>The above referenced AXIOMClient.java class is defined as
+follows, shown in Code Listing 9.</p>
+<p><b>Code Listing 9: The AXIOMClient class using AXIOM</b></p>
+<pre>
+package samples.quickstart.clients;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+
+public class AXIOMClient {
+
+    private static EndpointReference targetEPR = 
+        new EndpointReference(&quot;http://localhost:8080/axis2/services/StockQuoteService&quot;);
+
+    public static OMElement getPricePayload(String symbol) {
+        OMFactory fac = OMAbstractFactory.getOMFactory();
+        OMNamespace omNs = fac.createOMNamespace(&quot;http://axiom.service.quickstart.samples/xsd&quot;, &quot;tns&quot;);
+
+        OMElement method = fac.createOMElement(&quot;getPrice&quot;, omNs);
+        OMElement value = fac.createOMElement(&quot;symbol&quot;, omNs);
+        value.addChild(fac.createOMText(value, symbol));
+        method.addChild(value);
+        return method;
+    }
+
+    public static OMElement updatePayload(String symbol, double price) {
+        OMFactory fac = OMAbstractFactory.getOMFactory();
+        OMNamespace omNs = fac.createOMNamespace(&quot;http://axiom.service.quickstart.samples/xsd&quot;, &quot;tns&quot;);
+
+        OMElement method = fac.createOMElement(&quot;update&quot;, omNs);
+
+        OMElement value1 = fac.createOMElement(&quot;symbol&quot;, omNs);
+        value1.addChild(fac.createOMText(value1, symbol));
+        method.addChild(value1);
+
+        OMElement value2 = fac.createOMElement(&quot;price&quot;, omNs);
+        value2.addChild(fac.createOMText(value2,
+                                         Double.toString(price)));
+        method.addChild(value2);
+        return method;
+    }
+
+    public static void main(String[] args) {
+        try {
+            OMElement getPricePayload = getPricePayload(&quot;WSO&quot;);
+            OMElement updatePayload = updatePayload(&quot;WSO&quot;, 123.42);
+            Options options = new Options();
+            options.setTo(targetEPR);
+            options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+
+            ServiceClient sender = new ServiceClient();
+            sender.setOptions(options);
+
+            sender.fireAndForget(updatePayload);
+            System.err.println(&quot;price updated&quot;);
+            OMElement result = sender.sendReceive(getPricePayload);
+
+            String response = result.getFirstElement().getText();
+            System.err.println(&quot;Current price of WSO: &quot; + response);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+    
+}
+</pre>
+<p>Axis2 uses AXIOM, or the AXIs Object Model, a DOM (Document
+Object Model)-like structure that is based on the StAX API
+(Streaming API for XML). Here you setup the payload for the update
+and getPrice methods of the service. The payloads are created
+similar to how you created the getPriceResponse payload for the
+AXIOM service. Then you setup the Options class, and create a
+ServiceClient that you'll use to communicate with the service.
+First you call the update method, which is a fireAndForget method
+that returns nothing. Lastly, you call the getPrice method, and
+retrieve the current price from the service and display it.</p>
+<p>Now you can build and run the AXIOM client by typing ant
+run.client in the Axis2_HOME/samples/quickstartaxiom directory.</p>
+<p>You should get the following as output:</p>
+<pre>
+done
+Current price of WSO: 123.42
+</pre>
+<a name="clientadb"></a>
+<h3>Generating a Client using ADB</h3>
+<p>To build a client using Axis Data Binding (ADB), execute the
+following steps.</p>
+<p>Generate the client databings by typing the following in the
+Axis2_HOME/samples/quickstartadb directory:</p>
+<pre>
+%AXIS2_HOME%/bin/WSDL2Java -uri resources/META-INF/StockQuoteService.wsdl -p samples.quickstart.clients -d adb -s -o build/client
+</pre>
+<p>Else, simply type ant generate.client in the
+Axis2_HOME/samples/quickstartadb directory.</p>
+<p>Next take a look at
+quickstartadb/src/samples/quickstart/clients/ADBClient.java, and
+see how it's defined in Code Listing 10.</p>
+<p><b>Code Listing 10: The ADBClient Class</b></p>
+<pre>
+package samples.quickstart.clients;
+
+import samples.quickstart.service.adb.StockQuoteServiceStub;
+
+public class ADBClient{
+    public static void main(java.lang.String args[]){
+        try{
+            StockQuoteServiceStub stub =
+                new StockQuoteServiceStub
+                (&quot;http://localhost:8080/axis2/services/StockQuoteService&quot;);
+
+            getPrice(stub);
+            update(stub);
+            getPrice(stub);
+
+        } catch(Exception e){
+            e.printStackTrace();
+            System.err.println(&quot;\n\n\n&quot;);
+        }
+    }
+
+    /* fire and forget */
+    public static void update(StockQuoteServiceStub stub){
+        try{
+            StockQuoteServiceStub.Update req = new StockQuoteServiceStub.Update();
+            req.setSymbol (&quot;ABC&quot;);
+            req.setPrice (42.35);
+
+            stub.update(req);
+            System.err.println(&quot;price updated&quot;);
+        } catch(Exception e){
+            e.printStackTrace();
+            System.err.println(&quot;\n\n\n&quot;);
+        }
+    }
+
+    /* two way call/receive */
+    public static void getPrice(StockQuoteServiceStub stub){
+        try{
+            StockQuoteServiceStub.GetPrice req = new StockQuoteServiceStub.GetPrice();
+
+            req.setSymbol(&quot;ABC&quot;);
+
+            StockQuoteServiceStub.GetPriceResponse res =
+                stub.getPrice(req);
+
+            System.err.println(res.get_return());
+        } catch(Exception e){
+            e.printStackTrace();
+            System.err.println(&quot;\n\n\n&quot;);
+        }
+    }
+
+}
+</pre>
+<p>This class creates a client stub using the Axis Data Bindings
+you created. Then it calls the getPrice and update operations on
+the Web service. The getPrice method operation creates the GetPrice
+payload and sets the symbol to ABC. It then sends the request and
+displays the current price. The update method creates an Update
+payload, setting the symbol to ABC and the price to 42.35.</p>
+<p>Now build and run the client by typing ant run.client in the
+Axis2_HOME/samples/quickstartadb directory.</p>
+<p>You should get the following as output:</p>
+<pre>
+42
+price updated
+42.35
+</pre>
+<a name="clientxmlbeans"></a>
+<h3>Generating a Client using XMLBeans</h3>
+<p>To build a client using the XML Beans data bindings, execute the
+following steps.</p>
+<p>Generate the databings by typing the following in the
+xmlbeansClient directory.</p>
+<pre>
+%AXIS2_HOME%/bin/WSDL2Java -uri resources/META-INF/StockQuoteService.wsdl -p samples.quickstart.service.xmlbeans -d xmlbeans -s -o build/client
+</pre>
+<p>Else, simply type ant generate.client in the
+Axis2_HOME/samples/quickstartxmlbeans directory.</p>
+<p>Note that this creates a client stub code and no server side
+code.</p>
+<p>Next take a look at
+quickstartxmlbeans/src/samples/quickstart/clients/XMLBEANSClient.java,
+and see how it's defined in Code Listing 11.</p>
+<p><b>Code Listing 11: The XMLBEANSClient class</b></p>
+<pre>
+package samples.quickstart.clients;
+
+import samples.quickstart.service.xmlbeans.StockQuoteServiceStub;
+import samples.quickstart.service.xmlbeans.xsd.GetPriceDocument;
+import samples.quickstart.service.xmlbeans.xsd.GetPriceResponseDocument;
+import samples.quickstart.service.xmlbeans.xsd.UpdateDocument;
+
+public class XMLBEANSClient{
+
+    public static void main(java.lang.String args[]){
+        try{
+            StockQuoteServiceStub stub =
+                new StockQuoteServiceStub
+                (&quot;http://localhost:8080/axis2/services/StockQuoteService&quot;);
+
+            getPrice(stub);
+            update(stub);
+            getPrice(stub);
+
+        } catch(Exception e){
+            e.printStackTrace();
+            System.err.println(&quot;\n\n\n&quot;);
+        }
+    }
+
+    /* fire and forget */
+    public static void update(StockQuoteServiceStub stub){
+        try{
+            UpdateDocument reqDoc = UpdateDocument.Factory.newInstance();
+            UpdateDocument.Update req = reqDoc.addNewUpdate();
+            req.setSymbol (&quot;BCD&quot;);
+            req.setPrice (42.32);
+
+            stub.update(reqDoc);
+            System.err.println(&quot;price updated&quot;);
+        } catch(Exception e){
+            e.printStackTrace();
+            System.err.println(&quot;\n\n\n&quot;);
+        }
+    }
+
+    /* two way call/receive */
+    public static void getPrice(StockQuoteServiceStub stub){
+        try{
+            GetPriceDocument reqDoc = GetPriceDocument.Factory.newInstance();
+            GetPriceDocument.GetPrice req = reqDoc.addNewGetPrice();
+            req.setSymbol(&quot;BCD&quot;);
+
+            GetPriceResponseDocument res =
+                stub.getPrice(reqDoc);
+
+            System.err.println(res.getGetPriceResponse().getReturn());
+        } catch(Exception e){
+            e.printStackTrace();
+            System.err.println(&quot;\n\n\n&quot;);
+        }
+    }
+}
+</pre>
+<p>This class creates a client stub using the XML Beans data
+bindings you created. Then it calls the getPrice and the update
+operations on the Web service. The getPrice method operation
+creates the GetPriceDocument, its inner GetPrice classes and sets
+the symbol to ABC. It then sends the request and retrieves a
+GetPriceResponseDocument and displays the current price. The update
+method creates an UpdateDocument, updates and sets the symbol to
+ABC and price to 42.32, displaying 'done' when complete.</p>
+<p>Now build and run the the project by typing ant run.client in
+the Axis2_HOME/samples/quickstartxmlbeans directory.</p>
+<p>You should get the following as output:</p>
+<pre>
+42
+price updated
+42.32
+</pre>
+<a name="clientjibx"></a>
+<h3>Generating a Client using JiBX</h3>
+<p>To build a client using JiBX, execute the following steps.</p>
+<p>Generate the client stub by typing the following at a console in
+the Axis2_HOME/samples/quickstartjibx directory.</p>
+<pre>
+%AXIS2_HOME%/bin/wsdl2java -uri resources/META-INF/StockQuoteService.wsdl -p samples.quickstart.clients -d jibx -s -uw -o build/client
+</pre>
+<p>Else, simply type &quot;ant generate.client&quot;.</p>
+<p>Next take a look at
+quickstartjibx/src/samples/quickstart/clients/JiBXClient.java,
+shown below in Code Listing 12.</p>
+<p><b>Code Listing 12: The JiBXClient class</b></p>
+<pre>
+package samples.quickstart.clients;
+
+import samples.quickstart.service.jibx.StockQuoteServiceStub;
+
+public class JiBXClient{
+    public static void main(java.lang.String args[]){
+        try{
+            StockQuoteServiceStub stub =
+                new StockQuoteServiceStub
+                (&quot;http://localhost:8080/axis2/services/StockQuoteService&quot;);
+
+            getPrice(stub);
+            update(stub);
+            getPrice(stub);
+
+        } catch(Exception e){
+            e.printStackTrace();
+            System.err.println(&quot;\n\n\n&quot;);
+        }
+    }
+
+    /* fire and forget */
+    public static void update(StockQuoteServiceStub stub){
+        try{
+            stub.update(&quot;CDE&quot;, new Double(42.35));
+            System.err.println(&quot;price updated&quot;);
+        } catch(Exception e){
+            e.printStackTrace();
+            System.err.println(&quot;\n\n\n&quot;);
+        }
+    }
+
+    /* two way call/receive */
+    public static void getPrice(StockQuoteServiceStub stub){
+        try{
+            System.err.println(stub.getPrice(&quot;CDE&quot;));
+        } catch(Exception e){
+            e.printStackTrace();
+            System.err.println(&quot;\n\n\n&quot;);
+        }
+    }
+
+}
+</pre>
+<p>This class uses the created JiBX client stub to access the
+getPrice and the update operations on the Web service. The getPrice
+method sends a request for the stock &quot;ABC&quot; and displays the current
+price. The update method setsnex the price for stock &quot;ABC&quot; to
+42.35.</p>
+<p>Now build and run the client by typing &quot;ant run.client&quot; at a
+console in the Axis2_HOME/samples/quickstartjibx directory.</p>
+<p>You should get the following as output:</p>
+<pre>
+42
+price updated
+42.35
+</pre>
+<p>For more information on using JiBX with Axis2, see the <a href="jibx/jibx-codegen-integration.html">JiBX code generation
+integration</a> details.</p>
+<a name="summary"></a>
+<h2>Summary</h2>
+<p>Axis2 provides a slick and robust way to get web services up and
+running in no time. This guide presented five methods of creating a
+service deployable on Axis2, and four methods of creating a client
+to communicate with the services. You now have the flexibility to
+create Web services using a variety of different technologies.</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>
+
+</html>
+      </div>
+    </div>
+    <div class="clear">
+      <hr/>
+    </div>
+    <div id="footer">
+      <div class="xright">&#169;  
+          2004-2007
+    
+          Apache Software Foundation
+          
+  
+
+  
+    
+  
+  
+  </div>
+      <div class="clear">
+        <hr/>
+      </div>
+    </div>
+  </body>
+</html>



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


Mime
View raw message