You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ja...@apache.org on 2005/06/07 07:57:02 UTC

svn commit: r188703 - /webservices/axis/trunk/java/xdocs/userguide.html

Author: jaliya
Date: Mon Jun  6 22:57:01 2005
New Revision: 188703

URL: http://svn.apache.org/viewcvs?rev=188703&view=rev
Log:
Modified

Modified:
    webservices/axis/trunk/java/xdocs/userguide.html

Modified: webservices/axis/trunk/java/xdocs/userguide.html
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/xdocs/userguide.html?rev=188703&r1=188702&r2=188703&view=diff
==============================================================================
--- webservices/axis/trunk/java/xdocs/userguide.html (original)
+++ webservices/axis/trunk/java/xdocs/userguide.html Mon Jun  6 22:57:01 2005
@@ -122,13 +122,13 @@
 properly. (See <a href="installationguide.htm">Installation Guide</a>)</p>
 <h3>MyService</h3>
 <p>First let's see how we can write a simple Web Service (MyService) and deploy it. For this purpose we will create a Web Service with two operations as follows.</p>
-<pre class="style1 style2 style3">public void ping(OMElement element){} //IN-ONLY operation, just accepts the OMElement and do some processing.
-public OMElement echo(OMElement element){}//IN-OUT operation, accepts an OMElement and responds with another OMElement after processing.</pre>
+<pre><code>public void ping(OMElement element){} //IN-ONLY operation, just accepts the OMElement and do some processing.
+public OMElement echo(OMElement element){}//IN-OUT operation, accepts an OMElement and responds with another OMElement after processing.</code></pre>
 <p>Complete code for this example Web Service (MyService) can be found in the &quot;Axis2Home/samples/userguide/src&quot; directory under 
 &quot;userguide/example1&quot; package. As you can see, the two operations are very simple and need no explanations on what they are doing. So let's see how we can write the deployment descriptors for the service and deploy it.</p>
 <p>Axis2 uses &quot;service.xml&quot; to keep configurations for a Web Service. Each Web Service deployed 
 in Axis2 needs a &quot;service.xml&quot; containing the configurations. &quot;service.xml&quot; for MyService will be as follows; we will see what each parameter means later.</p>
-<pre class="style1 style2 style3">&lt;service name=&quot;MyService&quot;&gt;<br>    &lt;description&gt;<br>        This is a sample Web Service with two operations, echo and ping.<br>    &lt;/description&gt;<br>    &lt;parameter name=&quot;ServiceClass&quot; locked=&quot;xsd:false&quot;&gt;userguide.example1.MyService&lt;/parameter&gt;<br>    &lt;operation name=&quot;echo&quot;&gt;<br>        &lt;messageReceiver class=&quot;org.apache.axis.receivers.RawXMLINOutMessageRecevier&quot;/&gt;<br>    &lt;/operation&gt;<br>     &lt;operation name=&quot;ping&quot;&gt;<br>        &lt;messageReceiver class=&quot;org.apache.axis.receivers.RawXMLINOnlyMessageRecevier&quot;/&gt;<br>    &lt;/operation&gt;<br> &lt;/service&gt;</pre>
+<pre><code>&lt;service name=&quot;MyService&quot;&gt;<br>    &lt;description&gt;<br>        This is a sample Web Service with two operations, echo and ping.<br>    &lt;/description&gt;<br>    &lt;parameter name=&quot;ServiceClass&quot; locked=&quot;xsd:false&quot;&gt;userguide.example1.MyService&lt;/parameter&gt;<br>    &lt;operation name=&quot;echo&quot;&gt;<br>        &lt;messageReceiver class=&quot;org.apache.axis.receivers.RawXMLINOutMessageRecevier&quot;/&gt;<br>    &lt;/operation&gt;<br>     &lt;operation name=&quot;ping&quot;&gt;<br>        &lt;messageReceiver class=&quot;org.apache.axis.receivers.RawXMLINOnlyMessageRecevier&quot;/&gt;<br>    &lt;/operation&gt;<br> &lt;/service&gt;</code></pre>
 <p>As it can be seen, first line of the &quot;service.xml&quot; gives the name of the Web Service. This is used in the URL to the service as the service name. Next comes the description and the service class. The next two xml tags describe the operations that are available in this service with respective message receivers. For the &quot;echo&quot; operation we have used a <strong>RawXMLINOutMessageRecevier</strong> since it is an 
 IN-OUT operation. For IN-ONLY operation, &quot;ping&quot; we have used <strong>RawXMLINOnlyMessageRecevier</strong> as the message receiver. </p>
 <p>Axis2 use &quot;.aar&quot; (Axis Archive) file as the deployment package for Web Services. So, 
@@ -223,7 +223,7 @@
 Services&nbsp; and let's see how to use them Now!</b></p>
 <h3>EchoBlockingClient</h3>
 <p>Axis2 provides the user with several invocation patterns for Web Services, ranging from pure blocking single channel invocations to a non-blocking dual channel invocations. First let's see how we can write a client to invoke &quot;echo&quot; operation of &quot;MyService&quot; using the simplest good old blocking invocation. The client code that you need to write will be as follows.</p>
-<pre class="style1 style2 style3">  try {
+<pre><code>  try {
             OMElement payload = ClientUtil.getEchoOMElement();
             <span class="style10">Call call = new Call();
             call.setTo(targetEPR);
@@ -243,7 +243,7 @@
             e.printStackTrace();
         }
 }
-</pre></p>
+</code></pre></p>
 <p>The green lines shows the set of operations that you need to perform in-order to invoke a web service while the rest is used to create the OMElement that needs to be sent and to display the response OMElement. To test this 
 client you can use the &quot;TestEchoBlockingClient.bat&quot; that can be found in the &quot;Axis2Home/samples/userguide/src/userguide/clients/bin&quot; directory. The 
 .bat or .sh files show the required jars that needs to be there in the classpath for one to write Web Service clients using Axis2. So if you can see the response OMElement printed in your command line (as shown below)  then you have successfully tested the client as well. </p>
@@ -251,7 +251,7 @@
 <h3>PingClient</h3>
 <p>In the Web Service &quot;MyService&quot; we had a IN-ONLY operation with the name &quot;ping&quot; (see Web Services Using Axis2). So let's write a client to invoke this operation as well. 
 The client code will be as follows.</p>
-<pre class="style1 style2 style3"> try {
+<pre><code> try {
        OMElement payload = ClientUtil.getPingOMElement();
 
        MessageSender msgSender = new MessageSender();
@@ -262,7 +262,7 @@
      } catch (AxisFault axisFault) {
             axisFault.printStackTrace();
      }
-</pre>
+</code></pre>
 </p> 
 <p>Since we are accessing a IN-ONLY operation we can directly use the &quot;MessageSender&quot; to invoke this operation. As it can be seen in the above code , it is very straight forward to invoke this type of operation. MessageSender will not block the 
 invocation, hence it will return the control immediately back to the client. You can 
@@ -273,12 +273,12 @@
 <p>In the EchoBlockingClient once the &quot;call.invokeBlocking("echo", payload);&quot; is called, the client is blocked till the operation is completed. This behavior is not 
 desirable when there are many Web Service invocations to be done in a single client application. A solution, would be to use a Non-Blocking API to invoke web services. Axis2 provides a callback based non-blocking API for users. </p>
 <p>A sample client for this can be found under &quot;Axis2Home/samples/userguide/src/userguide/clients&quot; with the name EchoNonBlockingClient. If we consider the changes that the user may have to do with respect to the &quot;EchoBlockingClient&quot; that we have already seen, it will be as follows.</p>
-<pre class="style1 style2 style3">call.invokeNonBlocking(&quot;echo&quot;, payload, callback);</pre>
+<pre><code>call.invokeNonBlocking(&quot;echo&quot;, payload, callback);</code></pre>
 <p>The invocation  accepts a callback object as a parameter. Axis2 client API provides an 
 abstract Callback with the following methods.</p>
-<p><pre class="style1 style2 style3">public abstract void onComplete(AsyncResult result);
+<p><pre><code>public abstract void onComplete(AsyncResult result);
 public abstract void reportError(Exception e);
-public boolean isComplete() {}</pre></p>
+public boolean isComplete() {}</code></pre></p>
 <p>The user is expected to implement the &quot;onComplete &quot; and &quot;reportError &quot; methods of their extended call back class. Axis2 engine calls the onComplete method once the Web Service 
 response is received by the Axis2 Client API (Call). This will eliminate the blocking nature of the Web Service invocations and provides the user with the flexibility to use Non Blocking API for Web Service 
 Clients.</p>
@@ -300,7 +300,7 @@
 services (IN-OUT operations) using two separate transport connections. Let's see how we can do it using an example. Following code 
 fragment shows how to invoke the same &quot;echo&quot; operation, using Non-Blocking API with two transport 
 connections<strong>. The ultimate asynchrony!!</strong></p>
-<pre class="style1 style2 style3">  try {
+<pre><code>  try {
             OMElement payload = ClientUtil.getEchoOMElement();
 
             Call call = new Call();
@@ -338,15 +338,15 @@
             //Wait till the callback receives the response.
             while (!callback.isComplete()) {
                 Thread.sleep(1000);
-            }</pre>
-<pre class="style1 style2 style3">	  <font color="#33CC00">call.close();</font>
+            }</code></pre>
+<pre><code>	  <font color="#33CC00">call.close();</font>
 
         } catch (AxisFault axisFault) {
             axisFault.printStackTrace();
         } catch (Exception ex) {
             ex.printStackTrace();
         }
-</pre>
+</code></pre>
 <p>The three changes that we need do to the EchoNonBlockingClient are shown in the &quot;green&quot; color. Since our correlation mechanism is based on addressing we need 
 to first &quot;<strong>engage</strong>&quot; the addressing module.<span class="style15">
 <font color="#000000"><b>&quot;call.engageModule(new 
@@ -361,7 +361,7 @@
 phase (See <a href="Axis2ArchitectureGuide.html">Architecture Guide</a> for more 
 details about phases)&nbsp; and hence &quot;engaging&quot; means simply adding module reference in the &quot;server.xml&quot; (NOT the &quot;service.xml&quot;). Please add the following line to the &quot;server.xml&quot; that you can find in the &quot;/webapps/axis2/WEB-INF&quot; 
 directory in the servlet container. </p>
-<pre class="style1 style2 style3"> &lt;module ref=&quot;addressing&quot;/&gt;</pre>
+<pre><code> &lt;module ref=&quot;addressing&quot;/&gt;</code></pre>
 <p>Note: Please note that<span class="style15"><font color="#000000"> once you change the &quot;server.xml&quot; you need to restart the servlet container.</font></span></p>
 <p>This will enable the addressing in the server side and now you can test the &quot;TestEchoNonBlockingDualClient&quot; using the &quot;TestEchoNonBlockingDualClient.bat&quot; or &quot;TestEchoNonBlockingDualClient.sh&quot; provided under &quot;Axis2Home/samples/userguide/src/userguide/clients/bin&quot; directory. 
 If you can see the response OMElement printed in the client side, that means you 
@@ -407,9 +407,9 @@
 <p>LoggingModule is the implementation class of the Axis2 module. Axis2 modules 
 should implement the &quot;org.apache.axis.modules.Module&quot; interface with the 
 following methods.</p>
-<pre class="style1 style2 style3">public void init(AxisConfiguration axisSystem) throws AxisFault;//Initialize the module
+<pre><code>public void init(AxisConfiguration axisSystem) throws AxisFault;//Initialize the module
 public void shutdown(AxisConfiguration axisSystem) throws AxisFault;//End of module processing
-</pre>
+</code></pre>
 <p>These methods can be used to control the module initialization and the 
 termination. With the input parameter AxisConfiguration, the user is provided 
 with the complete configuration hierarchy and this can be used to fine tune the 
@@ -422,7 +422,7 @@
 invoke(MessageContext ctx);&quot; is the method that is called by the Axis2 engine 
 when the control is passed to the handler. &quot;public void revoke(MessageContext 
 ctx);&quot; is called when the handlers are revoked by the Axis2 engine. </p>
-<pre class="style1 style2 style3">public class LogHandler extends AbstractHandler implements Handler {
+<pre><code>public class LogHandler extends AbstractHandler implements Handler {
     private Log log = LogFactory.getLog(getClass());
     private QName name;
 
@@ -442,14 +442,14 @@
         this.name = name;
     }
 }
-</pre>
+</code></pre>
 <h4>Step3 : module.xml</h4>
 <p>&quot;module.xml&quot; contains the deployment configurations for a particular module. 
 It contains details such as Implementation class of the module (in this example 
 it is the &quot;LoggingModule&quot; class and the various handlers that will run in 
 different phases. &quot;module.xml&quot; for the logging module will be as follows.</p>
 <p>
-<pre  class="style1 style2 style3">&lt;module name=&quot;logging&quot; class=&quot;userguide.loggingmodule.LoggingModule &quot;&gt;
+<pre><code>&lt;module name=&quot;logging&quot; class=&quot;userguide.loggingmodule.LoggingModule &quot;&gt;
 &lt;inflow&gt;
 	&lt;handler name=&quot;InFlowLogHandler&quot; class=&quot;userguide.loggingmodule.LogHandler&quot;&gt;
 	&lt;order phase=&quot;loggingPhase&quot; /&gt;
@@ -473,7 +473,7 @@
 	&lt;order phase=&quot;loggingPhase&quot;/&gt;
 	&lt;/handler&gt;
 &lt;/INfaultflow&gt;
-&lt;/module&gt;</pre></p>
+&lt;/module&gt;</code></pre></p>
 
 <p>As it can be seen there are four phases defined in this &quot;module.xml&quot;</p>
 <ol>
@@ -495,10 +495,10 @@
 can reuse the same handler in all these phases, however this may not be the same 
 for all the modules. &quot;&lt;order phase=&quot;loggingPhase&quot; /&gt;&quot; describes the phase in 
 which this handler runs. </p>
-<pre  class="style1 style2 style3">&lt;handler name=&quot;InFlowLogHandler&quot; class=&quot;userguide.loggingmodule.LogHandler&quot;&gt;
+<pre><code>&lt;handler name=&quot;InFlowLogHandler&quot; class=&quot;userguide.loggingmodule.LogHandler&quot;&gt;
 &lt;order phase=&quot;loggingPhase&quot; /&gt;
 &lt;/handler&gt;
-</pre></p>
+</code></pre></p>
 
 <h4>Step 4: Modify the &quot;server.xml&quot;</h4>
 
@@ -512,7 +512,8 @@
 This is an extract of the phase section of the &quot;server.xml&quot;.</p>
 
 
-<pre  class="style1 style2 style3">&lt;!-- ================================================= --&gt;
+<pre><code>
+&lt;!-- ================================================= --&gt;
 &lt;!-- Phases --&gt;
 &lt;!-- ================================================= --&gt;
 &lt;phaseOrder type=&quot;inflow&quot;&gt;
@@ -522,31 +523,26 @@
 	&lt;phase name=&quot;Dispatch&quot;/&gt;
 	&lt;phase name=&quot;PostDispatch&quot;/&gt;
 &lt;!-- System pre defined phases --&gt;
-</pre>
-
 
-<pre  class="style1 style2 style3">&lt;!-- After Postdispatch phase module author or or service author can add any phase he want --&gt;
+&lt;!-- After Postdispatch phase module author or or service author can add any phase he want --&gt;
 &lt;phase name=&quot;<font color="#33CC00">loggingPhase</font>&quot;/&gt;
-&lt;/phaseOrder&gt;</pre>
-
+&lt;/phaseOrder&gt;
 
-<pre  class="style1 style2 style3">&lt;phaseOrder type=&quot;outflow&quot;&gt;
+&lt;phaseOrder type=&quot;outflow&quot;&gt;
 &lt;!-- user can add his own phases to this area --&gt;
 &lt;phase name=&quot;<font color="#33CC00">loggingPhase</font>&quot;/&gt;
-&lt;/phaseOrder&gt;</pre>
-
+&lt;/phaseOrder&gt;
 
-<pre  class="style1 style2 style3">&lt;phaseOrder type=&quot;INfaultflow&quot;&gt;
+&lt;phaseOrder type=&quot;INfaultflow&quot;&gt;
 &lt;!-- user can add his own phases to this area --&gt;
 &lt;phase name=&quot;<font color="#33CC00">loggingPhase</font>&quot;/&gt;
-&lt;/phaseOrder&gt;</pre>
-
+&lt;/phaseOrder&gt;
 
-<pre  class="style1 style2 style3">&lt;phaseOrder type=&quot;Outfaultflow&quot;&gt;
+&lt;phaseOrder type=&quot;Outfaultflow&quot;&gt;
 &lt;!-- user can add his own phases to this area --&gt;
 &lt;phase name=&quot;<font color="#33CC00">loggingPhase</font>&quot;/&gt;
 &lt;/phaseOrder&gt;
-</pre>
+</code></pre>
 
 
 <p>Shown in green, the custom phase &quot;loggingPhase&quot; is placed in all the flows, 
@@ -555,10 +551,8 @@
 phase for it to get executed.
 </p>
 
-
 <h4>Step5 : Modify the &quot;service.xml&quot;</h4>
 
-
 <p>Up to this point we have created the required classes and the configuration 
 descriptions for the logging module and by changing the &quot;server.xml&quot; we have 
 created the required phases for the logging module. Now the next step is to &quot;<b>engage</b>&quot; 
@@ -570,7 +564,7 @@
 directory. The simple changes that we have done to he &quot;service.xml' are shown in 
 the green color in the following lines of xml.</p>
 
-<p><pre  class="style1 style2 style3">&lt;service name=&quot;<font color="#33CC00">MyServiceWithModule</font>&quot;&gt;
+<p><pre><cod>&lt;service name=&quot;<font color="#33CC00">MyServiceWithModule</font>&quot;&gt;
 &lt;description&gt;
 This is a sample Web Service with a logging module engaged.
 &lt;/description&gt;
@@ -583,7 +577,7 @@
 &lt;messageReceiver class=&quot;org.apache.axis.receivers.RawXMLINOutMessageRecevier&quot;/&gt;
 &lt;/operation&gt;
 &lt;/service&gt;
-</pre></p>
+</code></pre></p>
 
 
 <p>In this example we have changed the service name (the implementatoin class is