What is the best/standard way to define a web service interface?
For example,
I have two class Car and Bus both of them extends Vehicle.
If I want to expose a create method for Car and Bus I have following options –
- public void create(Vehicle v);
- public void create(String type, Vehicle v);
- public void create(Car c); and public void create(Bus b);
- public void createCar(Vehicle v); and public void createBus(Vehicle v);
- public void createCar(Car c); and public void createBus(Bus b);
EDIT———————————
My main concern is of the above 5 options what is the standard way for a web service API. What is standard for java coding may not be standard for a webservice.
If you are interested in the standard way then none of those is.
Web services do not support operation overloading and it is prohibited in WS BP Profile
WS BP
This actually makes sense since the message mode (doc/lit) expects the operation name as the root of the message payload to do the dispatching.
Additionally, you are talking about OO concepts but web services standards are meant as an integration technology (not bind to specific languages or platforms).
In any case if you are expected to do that, you can implement overloading via tweeking at annotations and in your case, IMHO I think the best option would be
2so that the consumer knows how to downcast it.