axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cha...@apache.org
Subject svn commit: r491749 - /webservices/axis2/site/1_1/pojoguide.html
Date Tue, 02 Jan 2007 05:59:11 GMT
Author: chatra
Date: Mon Jan  1 21:59:09 2007
New Revision: 491749

URL: http://svn.apache.org/viewvc?view=rev&rev=491749
Log:
corrected issue regarding missing code in pre tags. 

Modified:
    webservices/axis2/site/1_1/pojoguide.html

Modified: webservices/axis2/site/1_1/pojoguide.html
URL: http://svn.apache.org/viewvc/webservices/axis2/site/1_1/pojoguide.html?view=diff&rev=491749&r1=491748&r2=491749
==============================================================================
--- webservices/axis2/site/1_1/pojoguide.html (original)
+++ webservices/axis2/site/1_1/pojoguide.html Mon Jan  1 21:59:09 2007
@@ -2,7 +2,7 @@
           @import url("../style/maven-base.css");
           
 			    @import url("../style/maven-theme.css");</style><link rel="stylesheet" href="../style/print.css"
type="text/css" media="print"></link><meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1"></meta></head><body class="composite"><div id="banner"><a
href="http://www.apache.org/" id="organizationLogo"><img alt="Apache Software Foundation"
src="http://www.apache.org/images/asf-logo.gif"></img></a><a href="http://ws.apache.org/axis2/"
id="projectLogo"><img alt="Apache Axis2" src="http://ws.apache.org/axis2/images/axis.jpg"></img></a><div
class="clear"><hr></hr></div></div><div id="breadcrumbs"><div
class="xleft">
-                	Last published: 14 November 2006
+                	Last published: 02 January 2007
                   | Doc for 1.1</div><div class="xright">
         
         <a href="../index.html">Axis2/Java</a>
@@ -75,7 +75,7 @@
   <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 at Axis2_HOME/samples/pojoguide
-&amp; Axis2_HOME/samples/pojoguidespring once you extract the <a href="../../download/1_1/download.html#std-bin">Axis2
Stadard
+&amp; Axis2_HOME/samples/pojoguidespring once you extract the <a href="../../download/1_1_1/download.html#std-bin">Axis2
Stadard
 Distribution</a>, and it might help to go grab it now to help you as you
 follow along. Let's get started.</p><p><a name="pojo"></a></p></div><div
class="subsection"><a name="The_POJO"></a><h3>The POJO</h3><p>The
POJO you'll be using throughout this document is a Weather service
 POJO that consists of two classes: WeatherService and Weather. Weather
@@ -185,14 +185,14 @@
   <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
+Axis2 1.1.1-bin and 1.1.1-war distributions <a href="../../download/1_1_1/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.1 Standard Binary (bin) Distribution) :</p>
+in the extracted Axis2 1.1.1 Standard Binary (bin) Distribution) :</p>
     <div class="source"><pre>&lt;property name="axis2.home" value="c:\apps\axis2"
/&gt;
 
 </pre></div>
   <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
+1.1.1-bin <a href="../../download/1_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>
     <div class="source"><pre> - WeatherService
@@ -209,7 +209,7 @@
   <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/" class="externalLink"
title="External Link">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
+<em>bin/startup.sh</em>. Once it's running, deploy the Axis2 1.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:
@@ -217,8 +217,7 @@
 the RPCServiceClient in the next section.</p><p><a name="testingpojows"></a></p></div><div
class="subsection"><a name="Testing_the_POJO_Web_Service_Using_RPCServiceClient"></a><h3>Testing
the POJO Web Service Using RPCServiceClient</h3><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>
-    <div class="source"><pre>package sample.pojo.rpcclient;
+values of the Weather class within the Web service (See Code Listing 4).</p><p><b>Code
Listing 4: Setting the weather</b></p><p><pre>package sample.pojo.rpcclient;
 
 import javax.xml.namespace.QName;
 
@@ -239,16 +238,24 @@
         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", "
-...
+            new QName("http://service.pojo.sample/xsd", "<b>setWeather");
 
-</pre></div>
-  <p>The most interesting code to note is in bold font. Notice the targetEPR
+        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><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
@@ -256,34 +263,48 @@
 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>
-    <div class="source"><pre>...
+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><p><pre>...
         serviceClient.invokeRobust(opSetWeather, opSetWeatherArgs);
 
         // Getting the weather
         QName opGetWeather =
-            new QName("http://service.pojo.sample/xsd", "
-...
+            new QName("http://service.pojo.sample/xsd", "<b>getWeather");
 
-</pre></div>
-  <p>First you set the operation in opGetWeather to getWeather. Then you create
+        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><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>
-    <div class="source"><pre>...
+to (see Code Listing 6).</p><p><b>Code Listing 6: Displaying the data</b></p><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());
         
-}
-
-</pre></div>
-  <p>You should receive the data shown in Code Listing 7.</p><p><b>Code
Listing 7: Output from running the client</b></p>
+    }</b>
+}</pre></p><p>You should receive the data shown in Code Listing 7.</p><p><b>Code
Listing 7: Output from running the client</b></p>
     <div class="source"><pre>rpc.client.run:
      [java] Temperature               : 39.3
      [java] Forecast                  : Cloudy with showers
@@ -310,23 +331,35 @@
 the Weather data in the Web service, since Spring does that for you using
 Inversion of Control (IoC), which is covered next.</p><p><a name="servicedef"></a></p></div><div
class="subsection"><a name="The_Service_Definition:_services_xml"></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>
-    <div class="source"><pre>&lt;serviceGroup&gt;
-  &lt;service "&gt;
+services in one file (see Code Listing 7).</p><p><b>Code Listing 7: Defining
the services: services.xml</b></p><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"&gt;
+        sample.spring.service.SpringInit
+    &lt;/parameter&gt;
+    &lt;parameter name="ServiceTCCL"&gt;composite&lt;/parameter&gt;
+    &lt;parameter name="load-on-startup"&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 "&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"&gt;
+        sample.spring.service.WeatherSpringService
+    &lt;/parameter&gt;
+    &lt;parameter name="ServiceObjectSupplier"&gt;
+org.apache.axis2.extensions.spring.receivers.SpringAppContextAwareObjectSupplier
+    &lt;/parameter&gt;
+    &lt;parameter name="SpringBeanName"&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;
@@ -334,10 +367,7 @@
       class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/&gt;
     &lt;/messageReceivers&gt;
   &lt;/service&gt;
-&lt;/serviceGroup&gt;
-
-</pre></div>
-  <p>You'll see a few familiar items in the above listing, and several changes.
+&lt;/serviceGroup&gt;</pre></p><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
@@ -352,20 +382,26 @@
 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>
-    <div class="source"><pre>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
+applicationContext.xml</b></p><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="" class=
+  &lt;bean id="<b>applicationContext</b>" class=
 "org.apache.axis2.extensions.spring.receivers.ApplicationContextHolder" /&gt;
 
-  
-&lt;/beans&gt;
-
-</pre></div>
-  <p>The first one is Axis2's hook into Spring's application context (needed
+  <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><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
@@ -380,25 +416,24 @@
 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>
-    <div class="source"><pre>    public void startUp(ConfigurationContext ignore,
+this class is shown in Code Listing 9.</p><p><b>Code Listing 9: SpringInit's
startUp method</b></p><p><pre>    public void startUp(ConfigurationContext
ignore,
                         AxisService service) {
-        (new String[]
-                                           {""}, 
+        <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></div>
-  <p>Note that this method retrieves the Spring class loader, creates an
+    }</pre></p><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></div><div
class="subsection"><a name="Build_and_Deploy_Using_Apache_Axis2_and_Tomcat"></a><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
+Before you build, you'll first need to make sure the axis2-spring-1.1.1.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 jars files to the service archive due to
cloass 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 over
 to <em>&lt;tomcat-home&gt;/webapps/axis2/WEB-INF/services</em>, and Axis2
@@ -410,7 +445,7 @@
 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>
     <div class="source"><pre>run.client:
-    [javac] Compiling 1 source file to C:\axis2-1.1\samples\pojoguidespring\build\cl
+    [javac] Compiling 1 source file to C:\axis2-1.1.1\samples\pojoguidespring\build\cl
 asses
      
 
@@ -419,4 +454,4 @@
 applicationContext.xml file!</p><p><a name="summary"></a></p></div><div
class="subsection"><a name="Summary"></a><h3>Summary</h3><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><p><a name="furtherstudy"></a></p></div><div
class="subsection"><a name="For_Further_Study"></a><h3>For Further Study</h3><p>Apache
Axis2-<a href="http://ws.apache.org/axis2/" class="externalLink" title="External Link">http://ws.apache.org/axis2/</a></p><p>Axis2
Architecture-<a href="http://ws.apache.org/axis2/1_0/Axis2ArchitectureGuide.html" class="externalLink"
title="External Link">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/"
class="externalLink" title="External Link">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"
class="externalLink" title="External Link">http://www.wso2.net/articles/axis2/java/2006/09/13/working-with-axis2</a></p><p>Apache
Tomcat-<a href="http://tomcat.apache.org/" class="externa
 lLink" title="External Link">http://tomcat.apache.org</a></p><p>Spring
Framework-<a href="http://www.springframework.org/" class="externalLink" title="External
Link">http://www.springframework.org/</a></p></div></div></div></div><div
class="clear"><hr></hr></div><div id="footer"><div class="xright">©
2004-2006, Apache Software Foundation</div><div class="clear"><hr></hr></div></div></body></html>
\ No newline at end of file
+Spring framework.</p><p><a name="furtherstudy"></a></p></div><div
class="subsection"><a name="For_Further_Study"></a><h3>For Further Study</h3><p>Apache
Axis2-<a href="http://ws.apache.org/axis2/" class="externalLink" title="External Link">http://ws.apache.org/axis2/</a></p><p>Axis2
Architecture-<a href="http://ws.apache.org/axis2/1_0/Axis2ArchitectureGuide.html" class="externalLink"
title="External Link">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/"
class="externalLink" title="External Link">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"
class="externalLink" title="External Link">http://www.wso2.net/articles/axis2/java/2006/09/13/working-with-axis2</a></p><p>Apache
Tomcat-<a href="http://tomcat.apache.org/" class="externa
 lLink" title="External Link">http://tomcat.apache.org</a></p><p>Spring
Framework-<a href="http://www.springframework.org/" class="externalLink" title="External
Link">http://www.springframework.org/</a></p></div></div></div></div><div
class="clear"><hr></hr></div><div id="footer"><div class="xright">©
2004-2007, Apache Software Foundation</div><div class="clear"><hr></hr></div></div></body></html>
\ 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


Mime
View raw message