File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes How do I return simple object via web services Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Web Services
Bookmark "How do I return simple object via web services" Watch "How do I return simple object via web services" New topic
Author

How do I return simple object via web services

avseq anthoy
Ranch Hand

Joined: Apr 27, 2004
Posts: 104
In the sample code listed below,I set return type as String


How do I set parameter that I can return simple object like Person



The completed code list below.
Thanks in advance.


My Way,My Pace
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
You have to use beam mapping concept of Axis.
An article on how to do this is available at http://radio.javaranch.com/balajidl/2006/03/22/1143041392434.html


Spritle Software Blogs
avseq anthoy
Ranch Hand

Joined: Apr 27, 2004
Posts: 104
Excuse me , I don't have to write wsdd or any other xml document to deploy my web service , because myeclipse or other IDE tools do these for me.
I wanna know about can I modify the paramters in the code so that I can get a simple object that web services return to me.

Thanks in advance.
Watsh Rajneesh
Ranch Hand

Joined: Apr 17, 2006
Posts: 110
If you already have a WSDL mentioning Person type as return type of web method then all you should be doing is :
QName QNAME_TYPE_PERSON = new QName("<Person namespace>", "PersonType");
call.setReturnType(QNAME_TYPE_PERSON);

example: <person namespace> as defined by your service wsdl could be http://examples.org/SayHello and PersonType could be a complex type in the wsdl. Complete WSDL as i see your problem is at the end of this reply.

and you cast the result to Person type:
Person person = (Person)call.invoke(params);

You will need to have the Person java bean class defined at client.

I too am learning webservices for now.. so this is no expert comment. Please treat this reply kindly and tell me if i am mistaken in understanding your question.

The Person class can be of the kind:




SCJP 5.0 (90%), SCDJWS 1.4 (88%), SCWCD 1.4 (82%), SCBCD 1.3 (85%)
Watsh Rajneesh
Ranch Hand

Joined: Apr 17, 2006
Posts: 110
Use WSDL-to-Java tools to generate support classes, even if using the dynamic proxy or DII approach.

For example, just to compile the client code, the developer must understand the WSDL for a service and generate by hand Java classes that match the parameter and return types defined in the WSDL document or, in the case of a dynamic proxy, the client-side representation of the service endpoint interface. These classes must be set up properly so that the JAX-RPC runtime can match SOAP message types to the corresponding Java objects.

Above comments are excerpted from chapter 5 of Blueprints Webservices book.

So you can either hand write the Person class or better yet have the WSDL2Java generate that for your DII client.
 
GeeCON Prague 2014
 
subject: How do I return simple object via web services