• 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:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

How to return Object as a Response (Please Reply)

 
Ranch Hand
Posts: 41
Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am trying to create webservice method which will return particular (Employee) object as a response.
I wrote following method to implement that :



I deployed this web service on a Glassfish server (in netbean6.0.1) successfully.

But when i try to call this method via web service client, I am not able to
give a argument to above function.
My Client calling code is as follows:


where argEmpIfo is of type List<org.beans.Employee> which is present at different web service.
Even though both Employee Classes have same strucure, I am getting incompatible type error.

So, Is there any other logic to return Object from a web service operation?

Please reply to this post, I am very new to web service development and I desperately looking for right direction to create a web servicce for my Company.
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I actually have the same question as you do. I have my own type in the server side, but I copy it into the client.

I can refer to the return type in the client code, but I have compiler error when building the client codes using Netbeans 6.1. I am still trying to figure it out.
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In a tool-based environment like netbeans you usually go through the following steps with the "contract last" approach:
  • Generate the SOAP request and response format from the server based methods and types and capture them in the WSDL web services contract.
  • Generate client types from the SOAP request and response formats described the WSDL.


  • That is serverType -> WSDL -> clientType

    As a result the client types are often different from the server types. If you have a true object (data + behavior) on the server side as an operation parameter then that object will simply become a "data transfer object" style bean (data + getter + setters without any business logic) on the client side.

    Web services aren't internet EJB!
    The web service provider and web service consumer simply exchange messages that contain semi-structured data - they do not exchange full-blown (java) objects.


    If you already have classes on the client side that you wish to use then you often have to write all the XML (un)marshalling code yourself. Axis2 offers the option of using JiBX in combination with the WSDL-to-Java code generation so that you only have to provide the XML mapping configuration.


    Originally posted by rushikesh kale:
    I desperately looking for right direction to create a web servicce for my Company.




    Well, then don't get entranced by the web service magic pixie dust and I suggest that you start looking at this type of information:

    Why Contract First?
    "Item 43: Recognize the object-hierarchical impedance mismatch" in Effective Enterprise Java: Ch.5: State Management (PDF)
    Example of Web Services
    Starting Out
    jaxb & object graphs
    Going crazy with webservices and Hibernate
    [ April 29, 2008: Message edited by: Peer Reynders ]
     
    Paper beats rock. Scissors beats tiny ad.
    Gift giving made easy with the permaculture playing cards
    https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
    reply
      Bookmark Topic Watch Topic
    • New Topic