Hi Oliver, Indeed I am not sure how the specs cover this topic.
As for (de)serializers, I am not using custom ones; I simply register a <beanMapping> (which uses the default Axis BeanSerializer and its Deser..Factory) for every concrete type [or rather, because my concrete types are obtained via a factory mechanism, I do these registrations programmatically]. - Altin -----Original Message----- From: Oliver Suciu [mailto:[EMAIL PROTECTED]] Sent: Saturday, March 09, 2002 3:36 AM To: [EMAIL PROTECTED] Subject: Re: interfaces as service parameters? Hi Altin, Yes -- makes sense: (1) the method parameter (or return) type declaration: <message name="findResponse"> <part name="findResult" type="intf:Book"/> </message> (2) the (interface/abstract) type definition: <complexType name="Book" abstract="true"/> To me, this seems straightforward: interfaces (or abstract classes) may be used as method parameters; and concrete objects (implementing those interfaces) are serialized/deserialized and sent back and forth between the web service and client. After all, you want to maintain your existing object-oriented design also in your web service app... But I'm trying to verify that the specs (JAX-RPC) actually cover these cases -- you never now... After all, they only added session management in the latest PFD 0.8 (and only for the servlet model, but hey, that works for me). However, why do you need custom serializers for your concrete types? Is it a limitation in the alpha, or is it required by design?... Thanks, -- Oliver "Papa, Altin" wrote: > > Hi Oliver, > > It seems that at least on the JAX-RPC list, this question usually just gets > one a lecture on interfaces having no constructors and thus being > non-serializable; quite puzzling. > Well, I had to expose services whose interfaces rely heavily on abstract > data types, so (finally) I have something similar working with alpha3 (it > may not be very orthodox as I am quite new at this -- I expect that the Axis > developers will be of more help). I apologise for the length of this > message, but if it helps... > > // some (bogus) illustrative code. The service methods are of the kind: > public Book find(BookId id) throws MyException; > > // concrete type to be returned: > public class Novel implements Book {...} > > I ran Java2Wsdl on the service class and got mostly OK WSDL, except that I > had to tweak the <schema> to show the derived object (see below), so you may > want to customize the generation of WSDL (I needed .NET to read this WSDL -- > reading a .XSD file was not working -- and generate C# proxy classes that > reflected my java side hierarchy, with a Book interface or abstract class at > the top of the hierarchy). > > The correct type mappings need to be registered, either in the .wsdd file > as: > <beanMapping qname="ns2:Book" languageSpecificType="java:my.pkg.Book" > xmlns:ns2="urn:SomeUniqueThing"/> > <beanMapping qname="ns2:Novel" languageSpecificType="java:my.pkg.Novel" > xmlns:ns2="urn:SomeUniqueThing"/> > <beanMapping qname="ns6:BookId" languageSpecificType="java:my.pkg.BookId" > xmlns:ns6="urn:SomeUniqueThing"/> > > or, if you have too many concrete types that are obtained via some factory > reg/lookup mechanism (as I do), you can register a custom type mapping > handler that will insert the mapping for Novel etc. into the registry: > <handler type="java:test.soap.MyTypeMappingHandler"/> > which does: > public class MyTypeMappingHandler extends BasicHandler { > public void invoke(MessageContext msgContext) throws > org.apache.axis.AxisFault { > TypeMappingRegistry tmr = msgContext.getTypeMappingRegistry(); > try { > BeanSerializer ser = new BeanSerializer(); > DeserializerFactory deser = ser.getFactory(); > ///////// THESE WOULD NOT BE HARDCODED BUT WOULD COME FROM > YOUR FACTORY > tmr.addSerializer(my.pkg.Novel.class, new > QName("urn:SomeUniqueThing","Novel"), ser); > tmr.addDeserializerFactory(new > QName("urn:SomeUniqueThing","Novel"), my.pkg.Novel.class, deser); > } > catch (Exception e) {... } } > > <schema targetNamespace="urn:SomeUniqueThing" > xmlns:intf="urn:SomeUniqueThing" xmlns="http://www.w3.org/2001/XMLSchema"> > <complexType name="BookId"> > <sequence> > <element name="id" type="string"/> > </sequence> > </complexType> > <element name="BookId" type="intf:BookId" nillable="true"/> > <complexType name="Book" abstract="true"> > <sequence> > <element name="bookId" type="intf:BookId"/> > </sequence> > </complexType> > <complexType name="Novel"> > <complexContent> > <extension base="intf:Book"> > <sequence> > <element name="author" > type="string"/> > <element name="title" > type="string"/> > <element name="version" type="int" > default="0"/> > </sequence> > </extension> > </complexContent> > </complexType> > <element name="Book" type="intf:Book" nillable="true"/> > <element name="Novel" type="intf:Novel" nillable="true"/> > <schema/> > .... > <message name="findRequest"> > <part name="arg0" type="intf:BookId"/> > </message> > <message name="findResponse"> > <part name="findResult" type="intf:Book"/> > </message> > ... > > .NET generated code: > <upon calling the service, in my client code I receive a C# Novel object> > ... > /// <remarks/> > [System.Xml.Serialization.SoapTypeAttribute("Book", "urn:SomeUniqueThing")] > [System.Xml.Serialization.SoapIncludeAttribute(typeof(Novel))] > public abstract class Book { > > /// <remarks/> > public BookId bookId; > } > > /// <remarks/> > [System.Xml.Serialization.SoapTypeAttribute("Novel", "urn:SomeUniqueThing")] > public class Novel : Book { > > /// <remarks/> > public string author; > > /// <remarks/> > public string title; > > /// <remarks/> > public int version; > } > ... > > -----Original Message----- > From: Oliver Suciu [mailto:[EMAIL PROTECTED]] > Sent: Thursday, March 07, 2002 2:51 AM > To: [EMAIL PROTECTED] > Subject: interfaces as service parameters? > > Hi all, > > Would the following work in Axis? And in JAX-RPC? > > // the service to be exposed: > public interface MyServiceProvider extends java.rmi.Remote { > public MyData doSomething(MyData someData) throws > java.rmi.RemoteException; > } > > // the interface that all data objects must implement: > public interface MyData extends java.io.Serializable { > } > > // some specific data object: > public class SpecificData implements MyData { > public boolean flag; > } > > ??? > > Thx, > > -- Oliver > > ******************************************************************* > DISCLAIMER: The information contained in this email > is confidential and is intended solely for the use of the > named addressee. Access, copying or re-use of the > information in it by any other person is not authorised. > > ******************************************************************** ******************************************************************* DISCLAIMER: The information contained in this email is confidential and is intended solely for the use of the named addressee. Access, copying or re-use of the information in it by any other person is not authorised. ********************************************************************