Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

How do I return simple object via web services

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
avseq anthoy
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:


 
Watsh Rajneesh
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic