WSO2 is now Choreo LabsLearn more

Trusted AI Governance
Build

Create agents and AI apps with the tools and languages your teams already use.

Connect

Link agents securely to your APIs, data, models and business systems.

Run

Deploy, observe and operate agents and AI apps reliably at any scale.

Govern

Control identity, access, cost and policy for every agent in production.

Agent Management

Developer Platform

  • API Management Cloud

    Design, secure and publish APIs with governance and analytics built in.

    Sign Up Now
  • Integration Cloud

    Connect apps, data and AI agents with low-code and pro-code integration.

    Sign Up Now
  • Identity & Access Management Cloud

    Secure sign-in and access for customers, partners, workforce and agents.

    Sign Up Now
  • Agent Management Cloud

    Build, run and govern AI agents with full visibility and control.

    Sign Up Now
  • Developer Platform Cloud

    Ship cloud-native apps faster on an internal developer platform.

    Sign Up Now

Self-Hosted

Full control over your stack. Deploy directly to your own servers, bare metal, cloud, or Kubernetes environment. Your data never leaves your perimeter.

Product Downloads
Choreo Labs
AI Governance
Platform
Solutions
Resources
Article

Create an Axis2 web service in 3 steps using eclipse - bottom up approach

Introduction

Within few minutes, you will learn how to create an axis2 web service using the eclipse IDE in just 3 easy steps.

The 3 steps are:

  1. Creating an Eclipse Project with WSO2 WSAS Facets added
  2. Add a Java Class to the project
  3. Make that Java class exposed as a web service

Prerequisites

Note: Visit the resources section of this tutorial to find out from where to download the prerequisites or click the above links.

Step 1 - Create a Dynamic Web Project with WSAS Facets

eclipse IDE
 

Go to File->New->Other... (Or "Ctrl + N")
Select Dynamic Web Project.

Type in a "Project name"

In "Target runtime" if "WSO2 WSAS 3.1" not available, click "New"
Select "WSO2 WSAS 3.1" from the list and click next.

Specify WSAS distribution path.

Click "Finish"

In "Configuration" click "Modify"

Tick/Check "WSAS Web Services" and click OK

Click "Finish"

Step 2 - Create the Java Class

Go to File->New->Other... (Or "Ctrl + N")


 

Select "Class" and click "Next"
Put the package name and name of the class

Click "Finish"

Lets have the following code.

package org.wso2.sample.webservice;

public class Area {
    
    public double getSquare(double sideLength){
        double area=sideLength*sideLength;
        return area;
    }
    
    public double getRectangle(double width, double height){
        double area=width*height;
        return area;
    }
    
    public double getTriangle(double baseLength, double height){
        double area=0.5*baseLength*height;
        return area;
    }
 
}

 

Step 3 - Make the class a Service

Select the Area.java class from "Project Explorer" view which is in the left handside of eclipse workspace.
Go to File->New->Other... (Or "Ctrl + N")

Select "Web Service" click "Next"

Click "Web service runtime" link and select "WSO2 Web Services Application Server" in the "Web service runtime" list box.

Click "OK".

Click "Finish"

Thats it. Your web service (provided that there aren't any syntax or coding errors) will be published in WSAS server.


 

When the WSAS server starts it will open the WSAS home page of WSAS server in an external browser. You can click the "List" link under services to see which services are available in the server.

Click on the "Try this service" link infront of the "Area" service to invoke your web service.

Resources

  1. Java class which we would create the web service from can be downloaded from here.
  2. To download WSO2 WSAS please visit https://wso2.org/projects/wsas/java
  3. To download WSO2 WSAS Tools please visit https://wso2.org/projects/tools/ or use the update site URL https://tools.wso2.org/eclipse

Summary

So creating a web service is easy. All you have to do is to point to the class which you want to make it a web service.

Click here to find out how to create a web service client for this service

Author

Saminda Wijeratne, Senior Software Engineer, WSO2, [email protected]