Hi folks,
I am new to web service development, i have been trying to develop a sample web service, but i see a problem in returning the custom data type from the web service.
complete details below:
my SEI is as below
@WebService
@SOAPBinding(style = Style.DOCUMENT)
public interface StudentService
{
/**
* Fetches the student object based on the student ID passed as parameter
* @param id the student ID
* @return the student object.
*/
@WebMethod
Student getStudent(
String id) throws StudentException;
}
my SIB is as below:
@WebService(endpointInterface = "com.jj.student.StudentService")
public class StudentServiceImpl implements StudentService
{
/**
* {@inheritDoc}
*/
public Student getStudent(String id) throws StudentException
{
// mock content for time being.
Student student = new Student("student01", new Name("first name",
"middle name", "last name"), 21, new Address());
return student;
}
}
I used wsgen to generate the WSDL, the problem i could see is the schema generated along with the wsdl doesnt seem to consider the class members of Stuent.java!
GENERATED SCHEMA
<?xml version='1.0' encoding='UTF-8'?><!-- Published by JAX-WS RI at
http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.7-b01-. --><xs:schema xmlns:tns="http://student.jj.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0" targetNamespace="http://student.jj.com/">
<xs:element name="StudentException" type="tns:StudentException" />
<xs:element name="getStudent" type="tns:getStudent" />
<xs:element name="getStudentResponse" type="tns:getStudentResponse" />
<xs:complexType name="getStudent">
<xs:sequence>
<xs:element name="arg0" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="getStudentResponse">
<xs:sequence>
<xs:element name="return" type="tns:student" minOccurs="0" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="student">
<xs:sequence />
</xs:complexType>
<xs:complexType name="StudentException">
<xs:sequence>
<xs:element name="message" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:schema>
if you observe, the student type has an empty sequence though i have class members for student!
I dont know where am i going wrong? why is it not generating the schema properly?
Thanks in advance
John