Hi Tom,
There are some options more or less "practical" to get what you want.
One is to replace your domain class with the generated one. This will
probably mean moving the "non-bean" functionality in your domain
Customer to another class, maybe something like "CustomerHelper". Of
course, this is not always possible, as you may have some internal
fields in your domain class you want to keep there.
Another option is to make your domain class to subclass the generated
class, or include it as an internal field.
Copying does not have to be so bad. If you have a fixed mapping between
what you have in your domain classes and what you want to return as XML
beans, you can implement the copying in a helper class. This will reduce
the probability of an error. If you use the same names for your bean
attributes in both classes, commons-beanutils maybe of help, as it
provides some methods to perform "conversions" between bean classes.
My own experience tells me that using the same object for internal and
XML binding purposes is not always a good idea. If your service modifies
the state of your domain objects, using them for serialization will
probably result in incoherences in your returned data.
Think about it. If you return your Customer, Axis 2 starts deserializing
it to build the response, and in another request somebody changes some
fields in the same object, the response may contain inconsistent data.
Take into account that, once you "release" your object to Axis, you
loose control over the transactionality of any operation on that instance.
I am not saying this is the end of the world. This scenario might not be
possible in your services, or even if possible, it may have little or no
importance. But if you do need returned data to be consistent, copying
field values into an XML bean may be the only way to get a valid
snapshot of your data.
Hope this helps,
Rodrigo Ruiz
[EMAIL PROTECTED] wrote:
Hi,
I'm struggling a bit with the following.
Say, I have a web service that allows you to search for customers. It
accepts a customer name, and returns a set (any number) of customers.
The response xml may look like
<customerSearchResponse>
<customer>
<number>123</number>
<name>John Doe</name>
</customer>
<customer>
<number>987</number>
<name>Jane Doe</name>
</customer>
</customerSearchResponse>
Obviously, in my application I have a Customer class. Now if I create a
wsdl for this web service, and generate the server side code for it, one
of the classes that is generated is a customer class, that represents
the customer in the xml response. On the other hand, I have the Customer
domain object, which is a different one. To generate the response, I
have to create 'xml response' customers, and basically copy the
information from the Customer class to it. The above example is very
simple, but you can imagine more complexe cases that would involve a lot
of copying from domain objects to xml representation objects. This is
very tedious and error-prone work -- typically work that I would like to
avoid.
Is there an elegant way to solve this issue?
Thanks,
Tom
------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.7.4/351 - Release Date: 29/05/2006
--
-------------------------------------------------------------------
GRIDSYSTEMS Rodrigo Ruiz Aguayo
Parc Bit - Son Espanyol
07120 Palma de Mallorca mailto:[EMAIL PROTECTED]
Baleares - EspaƱa Tel:+34-971435085 Fax:+34-971435082
http://www.gridsystems.com
-------------------------------------------------------------------
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.7.4/351 - Release Date: 29/05/2006
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]