You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Jürgen Bockhorn <Ju...@heuboe.de> on 2010/07/16 14:03:21 UTC

How to supply externally generated derived classes to a webservice

Hello,



We have the need to supply externally generated derived classes to a webservice.



Our approach is split:

On one hand we have a wsdl2java part that defines our 'webservice interface'. Within there is one empty abstract class that 'implments' an interface of our own.

This abstract class shall be later replaced by objects of concrete classes.



On the other hand there is an xmi driven datamodel. This one runs through a code generator of ours. The classes generated here are annotated with the appropriate JAXB annotations (@XmlAccessorType, @XmlType, @XmlElement, etc.). Furthermore they are derived from the abstract class above and really implement the interface mentioned above. An ObjectFactory is generated that is derived from the ObjectFactory of the wsdl2java part.



The third part (package) is the implementation of the service.



Finally I want to put these three parts together to a working webservice.



The situation now is as follows:

The service responds (running through the expected methods of the implementation). But the reply is filled with (empty) objects of the abstract base class.

I can fake the desired configuration when I manually add @XmlSeeAlso with a list of the generated classes to the abstract base class.

When I do that the respones are right and contain objects of the generated classes.



The whole thing is put to work using a spring configuration.



The final question is: Is there a way to supply the list of generated classes to the (prebuilt) webservice using a spring configuration.



What i already have vainly tried was adding a search list as property to the endpoint:

      <jaxws:endpoint xmlns:tns="http://gds.heuboe.de/iface/"

            id="simtdgds" implementor="#gds" wsdlLocation="wsdl/DataService.wsdl"

            endpointName="tns:DataServicePort" serviceName="tns:DataServer"

            address="/DataService">

            <jaxws:features>

                  <bean class="org.apache.cxf.feature.LoggingFeature" />

            </jaxws:features>

            <jaxws:properties>

                  <entry key="jaxb.search.packages">

                        <list>

                             <value>de.heuboe.gds.simtd</value>

                             <value>de.heuboe.gds.simtd.datakinds</value>

                              <value>de.heuboe.gds.simtd.domains</value></list></entry></jaxws:properties>

      </jaxws:endpoint>





Thanks in advance.


Jürgen


AW: How to supply externally generated derived classes to a webservice

Posted by Jürgen Bockhorn <Ju...@heuboe.de>.
Hallo Daniel,

your solution works perfect.

Thanx for your quick reply.

Jürgen

> -----Ursprüngliche Nachricht-----
> Von: Daniel Kulp [mailto:dkulp@apache.org]
> Gesendet: Freitag, 16. Juli 2010 16:51
> An: users@cxf.apache.org
> Cc: Jürgen Bockhorn
> Betreff: Re: How to supply externally generated derived classes to a
> webservice
> 
> 
> Take a look at:
> 
> http://svn.apache.org/repos/asf/cxf/trunk/systests/databinding/src/test
> /resources/extrajaxbclass.xml
> 
> which shows how to do exactly this.   That said, the @XmlSeeAlso is
> generally
> easier.   :-)
> 
> Dan
> 
> 
> On Friday 16 July 2010 8:03:21 am Jürgen Bockhorn wrote:
> > Hello,
> >
> >
> >
> > We have the need to supply externally generated derived classes to a
> > webservice.
> >
> >
> >
> > Our approach is split:
> >
> > On one hand we have a wsdl2java part that defines our 'webservice
> > interface'. Within there is one empty abstract class that 'implments'
> an
> > interface of our own.
> >
> > This abstract class shall be later replaced by objects of concrete
> classes.
> >
> >
> >
> > On the other hand there is an xmi driven datamodel. This one runs
> through a
> > code generator of ours. The classes generated here are annotated with
> the
> > appropriate JAXB annotations (@XmlAccessorType, @XmlType,
> @XmlElement,
> > etc.). Furthermore they are derived from the abstract class above and
> > really implement the interface mentioned above. An ObjectFactory is
> > generated that is derived from the ObjectFactory of the wsdl2java
> part.
> >
> >
> >
> > The third part (package) is the implementation of the service.
> >
> >
> >
> > Finally I want to put these three parts together to a working
> webservice.
> >
> >
> >
> > The situation now is as follows:
> >
> > The service responds (running through the expected methods of the
> > implementation). But the reply is filled with (empty) objects of the
> > abstract base class.
> >
> > I can fake the desired configuration when I manually add @XmlSeeAlso
> with a
> > list of the generated classes to the abstract base class.
> >
> > When I do that the respones are right and contain objects of the
> generated
> > classes.
> >
> >
> >
> > The whole thing is put to work using a spring configuration.
> >
> >
> >
> > The final question is: Is there a way to supply the list of generated
> > classes to the (prebuilt) webservice using a spring configuration.
> >
> >
> >
> > What i already have vainly tried was adding a search list as property
> to
> > the endpoint:
> >
> >       <jaxws:endpoint xmlns:tns="http://gds.heuboe.de/iface/"
> >
> >             id="simtdgds" implementor="#gds"
> > wsdlLocation="wsdl/DataService.wsdl"
> >
> >             endpointName="tns:DataServicePort"
> serviceName="tns:DataServer"
> >
> >             address="/DataService">
> >
> >             <jaxws:features>
> >
> >                   <bean class="org.apache.cxf.feature.LoggingFeature"
> />
> >
> >             </jaxws:features>
> >
> >             <jaxws:properties>
> >
> >                   <entry key="jaxb.search.packages">
> >
> >                         <list>
> >
> >                              <value>de.heuboe.gds.simtd</value>
> >
> >
> <value>de.heuboe.gds.simtd.datakinds</value>
> >
> >
> >
> <value>de.heuboe.gds.simtd.domains</value></list></entry></jaxws:proper
> tie
> > s>
> >
> >       </jaxws:endpoint>
> >
> >
> >
> >
> >
> > Thanks in advance.
> >
> >
> > Jürgen
> 
> --
> Daniel Kulp
> dkulp@apache.org
> http://dankulp.com/blog

Re: How to supply externally generated derived classes to a webservice

Posted by Daniel Kulp <dk...@apache.org>.
Take a look at:

http://svn.apache.org/repos/asf/cxf/trunk/systests/databinding/src/test/resources/extrajaxbclass.xml

which shows how to do exactly this.   That said, the @XmlSeeAlso is generally 
easier.   :-)

Dan


On Friday 16 July 2010 8:03:21 am Jürgen Bockhorn wrote:
> Hello,
> 
> 
> 
> We have the need to supply externally generated derived classes to a
> webservice.
> 
> 
> 
> Our approach is split:
> 
> On one hand we have a wsdl2java part that defines our 'webservice
> interface'. Within there is one empty abstract class that 'implments' an
> interface of our own.
> 
> This abstract class shall be later replaced by objects of concrete classes.
> 
> 
> 
> On the other hand there is an xmi driven datamodel. This one runs through a
> code generator of ours. The classes generated here are annotated with the
> appropriate JAXB annotations (@XmlAccessorType, @XmlType, @XmlElement,
> etc.). Furthermore they are derived from the abstract class above and
> really implement the interface mentioned above. An ObjectFactory is
> generated that is derived from the ObjectFactory of the wsdl2java part.
> 
> 
> 
> The third part (package) is the implementation of the service.
> 
> 
> 
> Finally I want to put these three parts together to a working webservice.
> 
> 
> 
> The situation now is as follows:
> 
> The service responds (running through the expected methods of the
> implementation). But the reply is filled with (empty) objects of the
> abstract base class.
> 
> I can fake the desired configuration when I manually add @XmlSeeAlso with a
> list of the generated classes to the abstract base class.
> 
> When I do that the respones are right and contain objects of the generated
> classes.
> 
> 
> 
> The whole thing is put to work using a spring configuration.
> 
> 
> 
> The final question is: Is there a way to supply the list of generated
> classes to the (prebuilt) webservice using a spring configuration.
> 
> 
> 
> What i already have vainly tried was adding a search list as property to
> the endpoint:
> 
>       <jaxws:endpoint xmlns:tns="http://gds.heuboe.de/iface/"
> 
>             id="simtdgds" implementor="#gds"
> wsdlLocation="wsdl/DataService.wsdl"
> 
>             endpointName="tns:DataServicePort" serviceName="tns:DataServer"
> 
>             address="/DataService">
> 
>             <jaxws:features>
> 
>                   <bean class="org.apache.cxf.feature.LoggingFeature" />
> 
>             </jaxws:features>
> 
>             <jaxws:properties>
> 
>                   <entry key="jaxb.search.packages">
> 
>                         <list>
> 
>                              <value>de.heuboe.gds.simtd</value>
> 
>                              <value>de.heuboe.gds.simtd.datakinds</value>
> 
>                              
> <value>de.heuboe.gds.simtd.domains</value></list></entry></jaxws:propertie
> s>
> 
>       </jaxws:endpoint>
> 
> 
> 
> 
> 
> Thanks in advance.
> 
> 
> Jürgen

-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog