Wed. Jan 26th, 2022

Requirement: In this post, I will describe how we can create a simple POJO based JAX-WS with Oracle JDeveloper.

JAX-WS is a Web Services framework that provides tools and infrastructure to develop Web Services solutions for the end users and middleware developers. Here we are going to create a JAX-WS with Oracle JDeveloper IDE.

Here, we will create a web service that shows Employees list with their Name, Designation, Salary and Department Name. Now, to do this, I am going to use POJO Class.

Solution: For solution of the above requirement follow the steps as shown below:

Step 1: Create a Java Desktop Application. For this click on New Application > Click Java Desktop Application > Click OK button

Step 2: Create a Java class. For this right click on the Client project > Click New > Click Java Class > Click OK

Give the Name of the Java class as EmployeeBean. Click OK

Step 3: Let us have four variables: name, designation, salary, and dept inside the EmployeeBean. Generate the accessors for each of these variables. Also, generate the parameterized constructors using all the above four fields.

Thus, the complete code for EmployeeBean.java is shown below:

package client;

public class EmployeeBean {
    private String name;
    private String designation;
    private Integer salary;
    private String departments;

    public EmployeeBean() {
        super();
    }

    public EmployeeBean(String name, String designation, Integer salary, String departments) {
        this.name = name;
        this.designation = designation;
        this.salary = salary;
        this.departments = departments;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setDesignation(String designation) {
        this.designation = designation;
    }

    public String getDesignation() {
        return designation;
    }

    public void setSalary(Integer salary) {
        this.salary = salary;
    }

    public Integer getSalary() {
        return salary;
    }

    public void setDepartments(String departments) {
        this.departments = departments;
    }

    public String getDepartments() {
        return departments;
    }
}

Step 4: Let us create one more Java class to hold Employees data and here we will make use of EmployeeBean class to add all the Employees information. Let the name of this class be Employees.

Here, we will add four Employee records.

Thus, the complete code for Employees.java is shown below:

package client;

import java.util.ArrayList;
import java.util.List;

public class Employees {
    public Employees() {
        super();
    }

    private List<EmployeeBean> employeeList = new ArrayList<EmployeeBean>();

    public void setEmployeeList(List<EmployeeBean> employeeList) {
        this.employeeList = employeeList;
    }

    public List<EmployeeBean> getEmployeeList() {
        if (employeeList.size() == 0) {
            employeeList.add(new EmployeeBean("Susanto Paul", "ADF Developer", 12000, "IT"));
            employeeList.add(new EmployeeBean("Moumita Deb", "UI Developer", 14000, "IT"));
            employeeList.add(new EmployeeBean("Anjali Paul", "Manager", 32100, "IT"));
            employeeList.add(new EmployeeBean("Nirmal Deb", "Architect", 31000, "IT"));
        }
        return employeeList;
    }
}

Step 5: Now we need to create a WebService. For this, simply add @WebService annotation just before Employees class name and import javax.jws.WebService package

Step 6: Click on yellow line under @WebSerice and select Configure Project for Web Services

In dialog select Java EE 6, with support for JAX-WS Annotations. Click OK

Thus, now our project project is configured for Web Services and a Web.xml file is created. Also, the icon of the Employees.java file is now changed as shown below:

Step 7: Now it’s a time to Test the WebService that we created just now. For this right click on Employees.java > Click Test Web Service.

This starts the Integrated WebLogic Server and initiates the HTTP Analyzer after deploying the WebService.

Thus, the ran application is shown below:

Click on the Send Request button, and with that we can see the result at the right hand side of the screen as shown below:

Hence, the solution to our requirement.

If you like the post please comment, share, and do join me on Facebook. Please subscribe to my YouTube Channel for video tutorials.

Thanks & Regards,
Susanto Paul

 448 total views,  3 views today

By Susanto Paul

Susanto is an Oracle ACE, a qualified MCA, MBA, and a highly-skilled Senior Oracle Specialist. He is an enthusiastic Blogger and YouTuber who helps learners to solve their complex problems more efficiently. He has 9+ years of experience in multiple technologies like AWS, Oracle ADF, Oracle APEX, Oracle JET, Oracle VBCS, Oracle IDCS, Oracle PL/SQL, Oracle Integration Cloud, Java, JDBC, Servlets, JSP, Spring, Hibernate, HTML5, CSS3, JavaScript, TypeScript, NodesJS, Angular, MySQL, Oracle WebLogic Server, JUnit, JMeter, Selenium Web Driver, etc. He is a certified: Oracle Certified Professional Java SE 6 Programmer, Oracle ADF 11g Certified Implementation Specialist, Oracle Cloud Platform Application Integration 2020 Certified Specialist, Oracle Cloud Infrastructure Foundations 2020 Certified Associate, and Oracle Cloud Infrastructure Developer 2020 Certified Associate

One thought on “Create POJO based JAX-WS with Oracle JDeveloper”

Leave a Reply

Your email address will not be published. Required fields are marked *

satta king chart