tags:

views:

128

answers:

2

Hello Experts,

I have a WebService that returns as the result of the Invokation of the Web-Service a ResponseObject called "CustomerResponse". When I implement this object "from scratch" everything works fine: My implementation in this case only contains all the needed "Simple Types" like Strings, Integers but NO Object references/associations.

However what I wanted to do is, "reuse" existing Objects. I have in my domain-model a "Customer" Object that is used in the Application itself. Instead of stupidly more or less cloning the Customer into the "CustomerReponse" object (by manually typing again all the members/fields), I wanted to base the CutomerResponse object on the Customer Object by extension:

class CustomerResponse extends Customer

==> The Problem is that now CustomerResponse contains some "internal" fields that were inherited from the Customer Object (like DatabaseID, Security-Stuff) that I do not want to expose via the Web-Service. Furthermore (and thats currently the main problem") Customer also contains a lot of "object references/associations" to other objects like Address, Orders, History that I do not want to expose via the Webservice either. (It seems that Apache CXF "evaluates" the whole Objectgraph and tries to include them in the ResponseObject...)

==> Is it possible to "Extend" WebService Response Objects based on existing Objects and somehow exclude some "members/fields" of the extended supertyp? (So I want to exclude some members (like the DatabseID) and all of the "object associations" like (Address/Orders/Histroy).. How can I acomplish this, with what annotations and procedures?

Thank you very much!! Jan

A: 

The @XmlTransient annotation is used to hide members which you do not want shown. You should be able to annotate these members, and they won't be bound. Alternatively, change your @XmlAccessorType to XmlAccessType.NONE and only specifically annotated methods will be bound to XML.

justkt
Hello KT, thank you very much for your answer. Well I actually tried @XMLTransient but it didnot work somehow. (Apache CXF nevertheless seemed to at least "crawl" the objectgraph on loading the Webservice and threw some exceptions (as My objectgraph has some identically named inner static Enums...). I will try again and will trry your XmlAccessType.NONE. Tanks!
jan
A: 

C# solves this problem with partial classes. I don't know how to do it with jax-ws.

Bob