You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by John Doyle <jd...@redhat.com> on 2010/02/16 23:55:56 UTC

Client advice for polymorphic service.

I'm looking for advice on the best kind of client to generate for a service.  

The service has operations like create and update that take an abstract Vehicle type as a parameter.  What's actually expected is a Car, Truck, Airplane or Skateboard, all of which are Vehicles, but are not defined as types in the WSDL.  Only Vehicle is defined and it contains an unbounded <any> to hold the properties of Car, Truck, etc.  I do know the properties of Car, Truck, etc from external info.

So my question is, what kind of client would be best.  If I generate the client with wsdl2java, I don't know how to add the properties of the derived classes so that they will be marshaled correctly.  Is there a class that I can use that will allow me to specify and name and value such that simple elements would be marshaled into the request?

I suspect that I may need to use the Dispatch API and create the XML myself?  Does that seem the best option?

Any feedback is appreciated.
Thanks
~jd

   

Re: Client advice for polymorphic service.

Posted by Daniel Kulp <dk...@apache.org>.
On Tue February 16 2010 5:55:56 pm John Doyle wrote:
> I'm looking for advice on the best kind of client to generate for a
> service.
> 
> The service has operations like create and update that take an abstract
> Vehicle type as a parameter.  What's actually expected is a Car, Truck,
> Airplane or Skateboard, all of which are Vehicles, but are not defined as
> types in the WSDL.  Only Vehicle is defined and it contains an unbounded
> <any> to hold the properties of Car, Truck, etc.  I do know the properties
> of Car, Truck, etc from external info.

What type of external info?   A separate XSD that we could run xsd->java on it 
to generate new types?   Or just a document of some sort describing it?

 
> So my question is, what kind of client would be best.  If I generate the
> client with wsdl2java, I don't know how to add the properties of the
> derived classes so that they will be marshaled correctly.  Is there a
> class that I can use that will allow me to specify and name and value such
> that simple elements would be marshaled into the request?

Well, if you generate from the wsdl, the <any> should map into a List<Object> 
type thing I think.   Each "Object" in there can just be a DOM element.  Thus, 
you can fill in the List with whatever properties are needed.

> 
> I suspect that I may need to use the Dispatch API and create the XML
> myself?  Does that seem the best option?

That's definitely one alternative.    Depending on the complexity of the XML, 
it may be the easiest.


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