I am new to web service and I am exploring one particular idea regarding this topic.
Supposed I have a java class like below
public class Department{
private int id;
private String name
private List<Employee> employees;
//getters and setters
}
I want to create a Web Service method and I wanted it to expose the data
to follow a certain schema when I call this web service. This will basically
be the SOAP response schema.
<department>
<id />
<name />
<employees type="list">
<employee>
<emp_id />
<name />
</employee>
.
.
</employees>
</department>
The web service method will just find a department given a department id input parameter.
The output should follow the schema above
@WebService
public class Service{
@WebMethod
public Department getDepartment(int id){
//code
}
}
Is this possible?
You need to annotate your POJO class with proper JAXB annotations.
Here is an example :
Also annotate your Employee class in the same manner.
And use