Re: Does Axis support polymorphism?

2005-06-22 Thread Anne Thomas Manes
Yes -- for interoperability reasons. Axis and other Java-based systems
can handle abstract types pretty easily, but other languages have a
lot more trouble with them. Web services should work with concrete XML
structures.

Anne

On 6/20/05, Steven Smith [EMAIL PROTECTED] wrote:
 
 Anne,
 Why should you avoid abstract types? Is it because of
 interoperability with other Web Service implementations? I have implemented
 a service that uses GML (Geographic Markup Language) to pass Spatial objects
 around. The GML specification uses abstract types heavily and I can't avoid
 that (without implementing my own). I have tested my service from an Axis
 client and it works fine as is, so I was wondering why abstract types should
 be avoided.
 
 
 
 --
 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: Anne Thomas Manes [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, 21 June 2005 6:28 AM
 To: axis-user@ws.apache.org
 Subject: Re: Does Axis support polymorphism?
 
 Avoid polymorphism and abstract types. Flatten your objects.
 
 Anne
 
 On 6/20/05, Amihai Fuks [EMAIL PROTECTED] wrote:
  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
 
 
 



RE: Does Axis support polymorphism?

2005-06-20 Thread Steven Smith
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