Skip to main content

Creating a Simple Axis Service(.aar file) and Deploy it in WSO2 Application Server


In this post I am explaining how to Create a Simple Axis Service(.aar file) and Deploy it in WSO2 Application Server using a simple sample. And also at the end I am describing how to do the same thing with creation of a Jar Service.

Lets assume "sample-home" as our parent directory and inside that we can create following folder structure.
Untitled

With this folder structure we can include our external libraries (jar files) inside lib folder and  the "services.xml" file inside "META-INF" folder. Following is the sample services.xml definition which I used with this sample creation.
<service name="HelloService"> 
<Description> 
This is a sample service to explain simple aar service 
</Description> 
<messageReceivers> 
<messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-out" 
class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/> 
</messageReceivers> 
<parameter name="ServiceClass" locked="false">org.wso2.hello.HelloAarService</parameter>        
</service>

Then we need to keep the service classes inside this "sample-home" directory. Here my HelloAarService.class is included inside the folder structure as shown in above according to my package structure. Following is the my HelloAarService.java class which I used to compile and create "HelloAarService.class" .
package org.wso2.hello;
public class HelloAarService {
public String serviceMethod() {
String var = "HelloService";
System.out.println(var);
return var;
}
}

Next Step is creating the .aar file and it is simply very smiler to creating a jar file. What we have to do is move into the "sample-home" folder and use following command. (Note: " HelloService.aar" is the created .aar file).
  jar -cvf  HelloService.aar *

After creating the .aar file you can Go to "Services > Add > Axis2 Service" in WSO2 AppServer and browse the created .aar file and upload it.

If you upload the file successfully you are almost done. Go to the "Services > List" and check weather your service(HelloService) is listed there. Also you can click on "Try This Service" option and test its functionality.

If you want to add the service as a JAR service you can ignore the services.xml file and META-INF folder(Just remove them) and create a jar file using following command.
  jar -cvf  HelloService.jar *

Then Go to "Services > Add > Jar Service" in WSO2 AppServer and browse the created .jar file and upload it. Then WSO2 AppServer directs you to a wizard which allows you to select "Classes to Expose as Web Services" and "Methods to be Exposed as Web Service Operations". Thats all and you can try the jar service using the same method as above. 

Comments

Post a Comment

Popular posts from this blog

How to install IBM WebSphere MQ on Ubuntu (Linux)

Following are the steps to install IBM WebSphere MQ version 8 on Ubuntu 14.04. 1) Create a user account with name "mqm" in Ubuntu. This should basically create a user called "mqm" and usergroup called "mqm" 2) Login to "mqm" user account and proceed with next steps 3) Increase the open file limit for the user "mqm" to "10240" or higher value. For this open "/etc/security/limits.conf" file and set the values as bellow. mqm       hard  nofile     10240 mqm       soft   nofile     10240 4) Increase the number of processes allowed for the user "mqm" to "4096" or higher value. For this open "/etc/security/limits.conf" file and set the values as bellow. You will need to edit this file as a sudo user. mqm       hard  nproc      4096 mqm       soft   nproc      4096 5) Install "RPM" on Ubuntu if you already don't have it. sudo apt-get install rpm   6) Download

How to use Dynamic Registry Keys with WSO2 ESB Mediators

From this post I will going to briefly introduce about one of the new features provided by WSO2 ESB . Earlier WSO2 ESB supported static registry keys where users can select a key for the mediator as a static value. But from ESB 4.0.0 users can use dynamic registry keys where users can define XPath expression to evaluate the registry key in run time. For an example let's consider XSLT mediator. With earlier static registry key based method user have to define only single XSLT file for transformation. With the use of dynamic registry key, user will be able to use XPath expressions to dynamically generate the registry key, based on the message context. So with that user can have multiple XSLT files and based on the evaluated key mediator will be able to select the required XSLT file in run time. Following is a sample usage of static and dynamic registry keys and user can use both of them according to situation.   Static Registry Key – define the exact path to find the xslt fil