permaculture playing cards*
The moose likes Web Services and the fly likes JAX WS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "JAX WS" Watch "JAX WS" New topic
Author

JAX WS

John Pradeep.v
Ranch Hand

Joined: Jul 21, 2008
Posts: 59
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

Joined: Jul 21, 2008
Posts: 59
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

Joined: Oct 04, 2006
Posts: 2198
    
    1
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

Joined: Jul 21, 2008
Posts: 59
Thanks Ivan, will check that ..
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JAX WS
 
Similar Threads
Query regarding RPC/Document Style,WSGEN and WSIMPORT
Https and wsdl
Creating a JMS TextMessage From XML
EJB3 WSException: Cannot obtain java type mapping
[schema] Allow an element to have any content