User Guide

contents

1 Introduction
2 Installing Axis-MORA
3 Publishing Web Services with Axis-Mora
3.1 How to run a service
3.2How to deploy a service
4 Using WSDL with Axis-Mora
4.1 WSDL2Ws:Building service class, wrapper and type classes from WSDL
Handler API
FAQ

1 Introduction

Welcome to axis-MORA !!! Axis-MORA is an open-source project at experimental level.

What is Axis-Mora?

Axis-Mora is a server side java implementation of a SOAP engine. It reuses all the subsystems of Axis1.1 except deserialization part and introduces a new concept called "wrappers" that is used to eliminate reflection. If you are interested in what are the changes in axis-Mora please refer "Change-log"

Let us know what you think !!

Please send feedback about the axis-Mora to "axis-user@ws.apache.org". If you feel the code could use some new features or fixes, please get involved and lend a hand!

We welcome your participation in axis-Mora discussion at axis-user@ws.apache.org .

Features of Axis-Mora

Axis-Mora uses pull structure for parsing xml. It eliminates reflection using a concept called "wrappers". Essentially the deserialization part of Axis1.1 has been replaced to produce Axis-Mora. Therefore it keeps all the key features of axis such as flexibility, stability, component-oriented deployment, transport framework and while it shows improvements in following areas.

2 Installing Axis-MORA

Binary is not available. Source can be downloaded from the repository. See build guide

3 Publishing Web Services with Axis-Mora

3.1 How to run a service

Example 1: Echo Service

Let's invoke a simple web service. You can get the code from samples/usergiude/example1/TestClient. We have the client as follows in


1  package userguide.example1;
2
3  import javax.xml.namespace.QName;
4  import javax.xml.rpc.ParameterMode;
5  import org.apache.axis.client.Call;
6  import org.apache.axis.client.Service;
7  import org.apache.axis.encoding.XMLType;
8
9  public class TestClient {
10
11   public static void main(String[] args)throws Exception {
12    try{
13     String endpoint= "http://127.0.0.1:8080/axismora/servlet/AxisServlet";
14
15     String SOAPAction = "Echo";   //you have to specify the service name as 16                                //SOAPAction
17     QName method = new QName("someuri", "echoString");
18
19     String echoString= args[0];
20
21     Service service = new Service();
22     Call call = (Call) service.createCall();
23     call.setOperationName(method);
24     call.setSOAPActionURI(SOAPAction);
25     call.addParameter("parameter", XMLType.XSD_STRING,ParameterMode.IN);
26     call.setReturnType(XMLType.XSD_STRING);
27     call.setTargetEndpointAddress(endpoint);
28     String ret = (String) call.invoke( new Object [] { echoString });
29     System.out.println("sent : '"+echoString + "', got :'"+ret+"'");
30    } catch (Exception e) {
31        System.err.println(e.toString());
32    }
33  }
34 }

This program could be run as follows,


% java userguide.example1.TestClient Hello
Sent :'Hello!', got :'Hello!'
%

So what's happening here? On lines 21 and 22 we create new Service and Call objects. These are the standard JAX-RPC objects that are used to store metadata about the service to invoke. on line 15, we specify the soapAction header and on line 24 we set up the soapAction header. Actually we send the service name through the soapAction header. On line 27, we set up our endpoint URL - this is the destination for our SOAP message. On line 17 we define the operation (method) name of the Web Service and we set that operation on the line 23. on line 26 we specify the return type. And on line 28 we actually invoke the desired service, passing in an array of parameters - in this case just one String.

3.2How to deploy a service

Example 2 Calculator Service

Step 1 : We should deploy the web service in Axis-Mora first.

Open the "deploy.wsdd" in samples/services/Calculator/deploy.wsdd. It looks as follows.

   <?xml version="1.0" encoding="UTF-8"?>
    <deployment xmlns="http://xml.apache.org/axis/wsdd/"xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="Calculator" provider="java:RPC">
    <parameter name="allowedMethods" value="*"/>
    <parameter name="className" value="services.calculator.CalculatorService"/>
</service>
</deployment>

The outermost element tells the engine that this is a WSDD deployment, and defines the "java" namespace. Then the service element actually defines the service for us. Using these tags, we give various information about our services. The parameter "className" tells the Axis engine where to find wrapper class name( we'll go into more details later ) , and "allowMethods" tell the engine that any public method on that class may be called. How to deploy ?

Copy the contents within the tags.

Open build/webapps/axismora/WEB-INF/mora-server.wsdd. Paste it as a immediate child of the tags of the mora-server.wsdd. The structure of the mora-server.wsdd should look as the following.

   <deployment xmlns="http://xml ........>
    <globalConfiguration>
                                   ....................
        <service name="CalculatorService" provider="java:RPC">
            ...........................................
        </service>
    <transport name="http">
        ....................................................
    </transport>
</deployment>

Now it is deployed.

Step 2: Client implementation of axis-Mora is not available. Client of Axis1.1 could be used to send SOAP request to Axis-MORA.You can get the Test Client from samples/userguide/example2/TestClient To execute the client program run the program.


%java samples.userguide.example2.TestClient -llhttp://localhost
:8080/axis/services/Calculator add 2 3

The result : 5 


4 Using WSDL with Axis-Mora

Axis-Mora supports WSDL for getting the service information and other details. The tool WSDL2Ws takes the wsdl and and get the information and create the web service, wrapper and necessary type classes. These classes will be generated automatically by this tool.

4.1 WSDL2Ws:Building service class, wrapper and type classes from WSDL

You can find the WSDL2Ws tool in "org.apache.axismora.wsdl2ws.WSDL2Ws". The basic invocation form looks like this:


java org.apache.axismora.wsdl2ws.WSDL2ws
wsdlfile -optionChar value

Way to get the arguments

    * wsdlfile: give the wsdl file name with correct path
    * optionChar: Optional characters can be given depends on the needs.

        Optional Characters

        * -o target output folder\n"
        * -l target language (c|java|c++) default is java
        * -i implementation style (struct|order|simple) default is struct
        * -s (client|server|both)

Example3

we have a wsdl file named "ArrayCalc.wsdl" in the samples/userguide/example3 folder. So the command will be

% java org.apache.axismora.wsdl2ws.WSDL2Ws ArrayCalc.wsdl -s server -o./example3 -ljava
Then there will be four classes named
  1. 1. ArrayCalcImpl--->This is the service class generated. You should fill it up with the logic. You can get the class from samples/userguide/example3/ArrayCalcImpl.java
  2. 2. ArrayCalcService--->This is the service wrapper class generated. It has the invoke method which invoke the exact service method.You can get the class from samples/userguide/example3/ArrayCalcService.java
  3. 3. ArrayOf_tns2_Point--->This is the array class which is used for deserialization and serialization for the array.You can get the class from samples/userguide/example3/ArrayOf_tns2_Point.java
  4. 4. Point--->This is the type class(Complex type) for deserialization and serilaization.You can get the class from samples/userguide/example3/Point.java

To make the service deployed you need to copy the below service tag and paste it in the mora-server.wsdd file.

<service name=="ArrayCalc" provider="java:RPC">
  <parameter name="allowedMethods" value="*"/>
  <parameter name="className" value=" userguide.example3.ArrayCalc"/>
</service>

To run this service users are expected to compile the generated classes and copy them in to the /webapps/axismora/WEB-INF/classes folder.

Handler API

The handler API follows JAX-RPC and SAAJ specifications. The implementation supports the SAAJ completely and covers the JAX-RPC functionally.

1.1 Handler

Handlers do not implement the JAX-RPC Handler interface. They follow axis handlers.

The Handler should implements the org.apache.axismora.Handler interface. The invoke method will be called by the axis engine.


public interface Handler {
        public void invoke(MessageContext msg);
        public void onFalult(MessageContext msg);
        public void init(Hashtable conf);
        public void cleanup();
        public void setOption(String name, Object value);
        public Object getOption(String name);
        public String getName();
        public QName[] getUnderstandHeaders(); 
}

1.2 SOAP Message Handler

A SOAP message handler class is required to implement the org.apache.axismora.Handler interface. This handler gets access to the SOAP message (that carries either an RPC request or response in the SOAP Body element) from the org.apache.axismora.MessageContext.

1.3 GenericHandler

The org.apcahe.axismora.handlers.BasicHandler class is an abstract class that implements the Handler interface. Handler developers should typically subclass the BasicHandler class unless the Handler implementation class needs another class as its super class.

1.4 HandlerChain

The org.apache.axismora.HandlerChain represents an ordered list of handlers. All Elements in the HandlerChain are of the type org.apache.axismora.Handler.


public interface HandlerChain extends Handler {
    public void add(Handler handler);
    public void remove(Handler handler);
}

1.5 HandlerInfo

The org.apache.axismor.handlers.HandlerInfo class represents the configuration data for a Handler. A HandlerInfo instance is passed in the Handler.init() method to initialize a Handler instance.


public class HandlerInfo implements java.io.Serializable {
    public HandlerInfo(Hashtable config) {...}
    public Hashtable getConfig() {...}
}

FAQ