Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JAX WS

 
John Pradeep.v
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
John Pradeep.v
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
okay, i have found the problem... its just that my custom data type which is the student class did'nt follow the bean standards (a default constructor and setter methods) but wsgen didnt flag any error about this..
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
I don't know if it helps, but have you used the verbose flag with wsgen?
Perhaps there are some warnings or hints regarding your Student class not following Java bean standard given when it is turned on?
Best wishes!
 
John Pradeep.v
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ivan, will check that ..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic