GeeCON Prague 2014*
The moose likes Web Services and the fly likes Shall I call a web service with Object type object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Web Services
Bookmark "Shall I call a web service with Object type object" Watch "Shall I call a web service with Object type object" New topic
Author

Shall I call a web service with Object type object

Amaresh Saha
Greenhorn

Joined: Mar 24, 2007
Posts: 4
In my application there are few web services,
1) Webservice1 takes input of Person object and returns Person object
2) Webservice2 takes input of Student object and returns Student object
3) Webservice3 takes input of Employee object and returns Employee object

The requirement is that -
instead of publishing all these webservices, shall i publish only one web service, which will take input of Object object and return object of Object object.

Within the web-service , I will expose a method say
Object callMe(Object o)
{
if(o instanceof Person)
{
..............
}
else if(o instanceof Student)
{
...............
}
return o;
}

Is it feasible ??

Regards,
Amresh
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
which will take input of Object object and return object of Object object.


Replace 'Object' with 'Document' and you are describing a document oriented web service. And as web services communicate with messages and not objects you may as well make that substitution. Document oriented web services don't have "web service methods" - they simply identify the kind of XML document that was submitted and then forward it to the appropriate process.

Document Handling Using JAX-WS Dispatch and Provider APIs describes how to implement document handling with JAX-WS.

Also have a look at this current thread about some very general design considerations regarding web services.

Beware of web service magic pixie dust.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Shall I call a web service with Object type object