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

Popular posts from this blog

Beautiful Trincomalee : One of the stunning places to visit in Sri-Lanka

Recently my self and few of my friends traveled to the ancient city of Trncomalee which is situated in eastern province and lies on the east cost of the little island. In ancient times it was identified as Gokanna and it was one of the major see ports in the international trading history of Sri Lanka. The city is home to the famous ancient Koneswaram Temple and it is said that this is the capital city of king Ravana.
This was my first travel to this ancient city and I would say that, it is one of the best places to visit in Sri Lanka. There are lot of places to visit there including Konesvaram Temple, Dutch Fort, Nilaveli Beach, Marble Beach and Pigeon Island. Nilaveli beach is considered to be one of the best beaches in Sri Lanka and Knee deep shallow seas spreads out hundreds of meters towards the sea. That provides ideal and pure conditions for sun bathing. Some of the pictures taken(by me and my friends) trough out the tour is listed bellow as a evidence to the stunning place. A…

Pub/Sub with WSO2 MB and WSO2 ESB using Durable and Hierarchical Topics

WSO2 MB is a standers complaint  message broker which supports JMS and AMQP standards and it will allow interoperability between many languages. It supports two of the main standers patterns of communication.

Point-to-Point messaging through queues where one application sends messages directly to another application. Publish/Subscribe pattern through topics where one application publishes messages to a topic and other applications who are subscribed to this topic will receive these messages. This post will explain how to use WSO2 ESB as a publisher and subscriber for WSO2 MB which will act as the middle hub for message exchange. Also it will explain the hierarchical topic capabilities and durable topic capabilities of WSO2 MB.

As an example lets take a news publisher service which publishes various types of news. And there are subscribers who are interested on various types of news.


Download and unzip WSO2 ESB 4.8.1 and WSO2 MB 2.1.0Locate wso2mb-2.1.0/bin folder and start wso2mb-2.1.…