0

I have this SOAP web service

request/response

    import javax.xml.bind.annotation.XmlElement;
    public class EmployeeRequest {
        private String firstName;
        //getters and setters with annotation @XmlElement on getters
    }

    import javax.xml.bind.annotation.XmlElement;
    public class Employee {
        private int id;
        private String firstName;
   //getters and setters with annotation @XmlElement on getters
    }

Interface/Implementation

import javax.jws.WebMethod;
import javax.jws.WebService;

@WebService
public interface EmployeeService {

    @WebMethod
    Employee getEmployee(EmployeeRequest request);
}

import javax.jws.WebMethod;
import javax.jws.WebService;

@WebService(endpointInterface = "org.example.EmployeeService")
public class EmployeeServiceImpl implements EmployeeService {

    @WebMethod
    public Employee getEmployee(EmployeeRequest request) {
        Employee employee = new Employee();
        employee.setId(1);
        employee.setFirstName(request.getFirstName() + ", hello");
        return employee;
    }
}

and main class

import javax.xml.ws.Endpoint;

public class Main {
    public static void main(String[] args) {
        Endpoint.publish("http://localhost:8080/employeeservice", new EmployeeServiceImpl());
    }
}

It works fine and uses standard JDK-based jax-ws implementation (JAX-WS RI Runtime Bundle) because I don't have any dependencies in my pom.xml. Correct me if I am wrong.

Now I want to try the Glassfish Metro implementation (https://stackoverflow.com/a/12670288/11926338):

JAX-WS is an API while Metro is the reference implementation for the JAX-WS API; both are from Sun/Oracle, thus are standard. You can see them as an interface (JAX-WS) and a class implementing the interface (Metro), only at a higher level. Glassfish also uses Metro as implementation for JAX-WS.

How can I switch my project to the Metro? I tried to add a couple of dependencies:

<dependencies>
    <dependency>
        <groupId>org.glassfish.metro</groupId>
        <artifactId>webservices-rt</artifactId>
        <version>4.0.2</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish.metro</groupId>
        <artifactId>webservices-api</artifactId>
        <version>4.0.2</version>
    </dependency>
</dependencies>

and it continues to work but I don't understand what implementation is using.

Pavel Petrashov
  • 1,073
  • 1
  • 15
  • 34

0 Answers0