Hi,
What you are describing is not polymorphism. Polymorphism is when
you have objects that implement a common interface but change the
implementations of the methods for that interface. In your example, an
instance of polymorphism would be a draw method on each Shape object. Each
different type of Shape draws itself differently, even though they are
called through a common method.
In the case of Web Services, polymorphism could be achieved by
having many Services that publish the same interface, but actually implement
that interface differently. For your example it could be that 1 Service adds
the Shape to a file, but another Service adds the Shape to a database. So
the polymorphism comes into it by the Service you choose to use.
I think what you are trying to ask is will the Web Service handle
any type of Shape object, even though the Service only explicitly mentions
the abstract Shape class. The answer to that is yes, it will, because Java
supports inheritance, it has nothing to do with Axis or Web Services.
Note: Even though there is no need for it, you could provide an add
method for each concrete type of Shape and you would not need to flatten
your object hierarchy, you could still use inheritance. It would just not
use that inheritance to its advantages.
Summary: A Service that publishes the addShape(Shape) method will
accept any type of Shape object provided the WSDL has a definition for that
object.
--
Steven Smith [EMAIL PROTECTED]
Software Developer / Analyst
Telephone: 03 6223 1999
Facsimile: 03 6223 1988
Web : www.geometry.com.au
Address : 31 Salamanca Square, Battery Point, TAS 7004, Australia
Postal : PO Box 844, Sandy Bay, TAS 7006, Australia
-Original Message-
From: Amihai Fuks [mailto:[EMAIL PROTECTED]
Sent: Monday, 20 June 2005 6:51 PM
To: axis-user@ws.apache.org
Subject: Does Axis support polymorphism?
Hi,
I am new to Axis (and SOAP in general...). Does Axis support polymorphism in
the service's methods? I'll give an example: is it a good practice to expose
a method like:
public void addShape(Shape shape);
Where Shape is an abstract type and there are several implementations for
the type like: Square and Rectangle (as you may guess).
Or maybe try avoid it through flattening my objects resulting in duplication
of logic applied to all Shapes and having as much Shapes I have addShape
methods.
Notice that I have no idea who my clients are and how they handle the SOAP
on their side.
Thanks, Amihai