Hi again, Finally I managed to configure the client to react to the inheritance. I have to configure the ReflectionServiceFactoryBean of the ClientProxyFactoryBean with the same properties map I have used to configure the Server Side.
Client Code: ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); Map props = new HashMap(); List list = new ArrayList(); list.add(DummySon.class.getName()); props.put("writeXsiType", Boolean.TRUE); props.put("overrideTypesList", list); factory.getServiceFactory().setProperties(props); factory.setDataBinding(new AegisDatabinding()); factory.setServiceClass(GetDummyWS.class); factory.setAddress("http://localhost:8080/services/GetDummy"); GetDummyWS client = (GetDummyWS)factory.create(); Dummy dummy = (Dummy) client.doService(); DummySon dummyson = (DummySon) dummy; System.out.println("SonField:" +dummySon.getSonField()); InJeNiErO InJeNiErO wrote: > > Hi, > > I managed to configure the simple frontend to produce a WSDL with > inheritance using AEGIS, but I can't make the client to work with the > inheritance, it throws a ClassCastException when trying to cast to the > childClass. > > Here is my spring configuration: > > <bean id="aegisBean" > class="org.apache.cxf.aegis.databinding.AegisDatabinding" > scope="prototype" /> > <bean id="simple-and-aegis-service-factory" > class="org.apache.cxf.service.factory.ReflectionServiceFactoryBean" > scope="prototype"> > <property name="dataBinding" ref="aegisBean" /> > <property name="serviceConfigurations"> > <list> > <bean > class="org.apache.cxf.service.factory.DefaultServiceConfiguration" /> > <bean > class="org.apache.cxf.aegis.databinding.AegisServiceConfiguration" /> > </list> > </property> > <property name="properties"> > <map> > <entry key="writeXsiType"> > <value > type="java.lang.Boolean">true</value> > </entry> > <entry key="overrideTypesList"> > <list> > > <value>testapplication.model.DummySon</value> > > <value>testapplication.model.DummyGrandSon</value> > </list> > </entry> > </map> > </property> > </bean> > > <simple:server id="getDummyWS" > serviceClass="testapplication.ws.GetDummyWS" address="/GetDummy" > serviceBean="#getDummyWSImp"> > <simple:serviceFactory> > <ref bean="simple-and-aegis-service-factory" /> > </simple:serviceFactory> > </simple:server> > > And the GetDummyWSImp Cass: > > public class GetDummyWSImp implements GetDummyWS{ > public Dummy doService(String name){ > DummySon ds = new DummySon(); > ds.setBirth(new Date(2001,10,14)); > ds.setCode(new Long(45)); > ds.setName(name); > ds.setSonField("sondField"); > return ds; > } > } > > And the Dummy, DummySon and DummyGrandSon classes: > > public class Dummy { > private String name; > private Long code; > private Date birth; > (plus getter and setters) > } > public class DummySon extends Dummy { > private String sonField; > (plus getter and setters) > } > public class DummyGrandSon extends DummySon { > private String grandSonField; > (plus getter and setters) > } > > And finally the WSDL: > > <?xml version="1.0" encoding="utf-8"?><wsdl:definitions > xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" > xmlns:tns="http://ws.testapplication/" > xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" > xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="GetDummyWS" > targetNamespace="http://ws.testapplication/"> > <wsdl:types> > <xsd:schema xmlns:tns="http://model.testapplication" > attributeFormDefault="qualified" elementFormDefault="qualified" > targetNamespace="http://model.testapplication"> > <xsd:complexType name="DummyGrandSon"> > <xsd:complexContent> > <xsd:extension base="tns:DummySon"> > <xsd:sequence> > <xsd:element minOccurs="0" name="grandSonField" > nillable="true" type="xsd:string"/> > </xsd:sequence> > </xsd:extension> > </xsd:complexContent> > </xsd:complexType> > <xsd:complexType name="DummySon"> > <xsd:complexContent> > <xsd:extension base="tns:Dummy"> > <xsd:sequence> > <xsd:element minOccurs="0" name="sonField" > nillable="true" type="xsd:string"/> > </xsd:sequence> > </xsd:extension> > </xsd:complexContent> > </xsd:complexType> > <xsd:complexType name="Dummy"> > <xsd:sequence> > <xsd:element minOccurs="0" name="birth" type="xsd:dateTime"/> > <xsd:element minOccurs="0" name="code" nillable="true" > type="xsd:long"/> > <xsd:element minOccurs="0" name="name" nillable="true" > type="xsd:string"/> > </xsd:sequence> > </xsd:complexType> > </xsd:schema> > <xsd:schema xmlns:ns0="http://model.testapplication" > attributeFormDefault="unqualified" elementFormDefault="qualified" > targetNamespace="http://ws.testapplication/"> > <xsd:element name="doService" type="tns:doService"/> > <xsd:complexType name="doService"> > <xsd:sequence> > <xsd:element minOccurs="0" name="arg0" type="xsd:string"/> > </xsd:sequence> > </xsd:complexType> > <xsd:element name="doServiceResponse" type="tns:doServiceResponse"/> > <xsd:complexType name="doServiceResponse"> > <xsd:sequence> > <xsd:element minOccurs="0" name="return" type="ns0:Dummy"/> > </xsd:sequence> > </xsd:complexType> > </xsd:schema> > </wsdl:types> > <wsdl:message name="doService"> > <wsdl:part element="tns:doService" name="parameters"> > </wsdl:part> > </wsdl:message> > <wsdl:message name="doServiceResponse"> > <wsdl:part element="tns:doServiceResponse" name="parameters"> > </wsdl:part> > </wsdl:message> > <wsdl:portType name="GetDummyWSPortType"> > <wsdl:operation name="doService"> > <wsdl:input message="tns:doService" name="doService"> > </wsdl:input> > <wsdl:output message="tns:doServiceResponse" > name="doServiceResponse"> > </wsdl:output> > </wsdl:operation> > </wsdl:portType> > <wsdl:binding name="GetDummyWSSoapBinding" > type="tns:GetDummyWSPortType"> > <soap:binding style="document" > transport="http://schemas.xmlsoap.org/soap/http"/> > <wsdl:operation name="doService"> > <soap:operation soapAction="" style="document"/> > <wsdl:input name="doService"> > <soap:body use="literal"/> > </wsdl:input> > <wsdl:output name="doServiceResponse"> > <soap:body use="literal"/> > </wsdl:output> > </wsdl:operation> > </wsdl:binding> > <wsdl:service name="GetDummyWS"> > <wsdl:port binding="tns:GetDummyWSSoapBinding" name="GetDummyWSPort"> > <soap:address location="http://localhost:8080/services/GetDummy"/> > </wsdl:port> > </wsdl:service> > </wsdl:definitions> > > InJeNiErO. > >>I pessimistically think that you've found a bug. Could you please drop >>this into JIRA? > >> -----Original Message----- >> From: Segal, Jeffrey [mailto:[EMAIL PROTECTED] >> Sent: Thursday, November 01, 2007 4:31 PM >> To: cxf-user@incubator.apache.org >> Subject: Migrating XFire/Aegis inheritance to CXF >> >> I'd like to bump the question posed a few weeks ago by Nalyd (see >> http://www.nabble.com/Aegis-inheritance-tf4668138.html#a13335122). >> >> I am attempting to ensure that some additional classes which are not >> present in my service interfaces get bound along with the others, a >> common problem given a service such as: >> >> public void queue(Job job); >> >> where there exists the following classes: >> >> public class BigJob extends Job { ... } >> public class SmallJob extends Job {...} >> >> In this case, Job will be bound to XML elements, but BigJob and > SmallJob >> will not. XFire does support this, documented at >> http://xfire.codehaus.org/Aegis+Inheritance. However, I cannot find a >> similar piece of documentation on porting this solution to CXF. It >> seems as if the support is all still there but not necessarily exposed >> (see http://cwiki.apache.org/CXF20DOC/aegis-theory-of-operation.html). >> >> I have played around with a few things in my Spring configuration, > such >> as adding something like this to my ServiceFactoryBean: >> >> <bean id='jaxws-and-aegis-service-factory' >> class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean"> >> ... >> <property name="properties"> >> <map> >> <entry key="writeXsiType"> >> <value type="java.lang.Boolean">true</value> >> </entry> >> <entry key="overrideTypesList"> >> <list> >> <value>com.foo.bar.BigJob</value> >> <value>com.foo.bar.SmallJob</value> >> </list> >> </entry> >> </map> >> </property> >> ... >> </bean> >> >> This deploys without error, but my WSDL and corresponding stubs do not >> include the overridden types. Any ideas? >> >> Thanks! >> Jeff > > -- View this message in context: http://www.nabble.com/Migrating-XFire-Aegis-inheritance-to-CXF-tp13536859p15413115.html Sent from the cxf-user mailing list archive at Nabble.com.