axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Naresh Bhatia" <NBha...@sapient.com>
Subject Exposing complex business objects using Axis
Date Mon, 21 Jul 2003 15:18:31 GMT
Hello Axis users,

I have been using Axis for over a year now and I have deployed two
production applications using it. I wanted to discuss some of the
hurdles I faced during this work and find out if others have faced
similar problems too. Finally, I would like to share some code that has
helped me cross these hurdles and get your feedback on it.

The most difficult task for me was to expose complex business objects
using Axis (or any other SOAP toolkit for that matter). Both my
applications demanded rich business objects that involved multiple
levels of nesting and full use of Java container classes such as Lists
and Maps. After lot of effort it became apparent that SOAP toolkits
could not easily send and receive these data structures. For example,
here's a trivial business object that uses a java.util.Map.

public class Meeting implements Serializable {
    private String meetingId;
    private String subject;
    private String location;
    private Date startTime;
    private Date endTime;
    private Map attendees;
    ...
}

Most SOAP toolkits do not "prefer" to deal with maps and forced me to
declare the attendees member as an array. Some toolkits even offered to
serialize/deserialize the maps, but I found that their solutions would
not interoperable with other toolkits. So I was either stuck with an
array, or I had to keep two sets of objects - one for internal use and
the other for exposing to the Web. Of course, the latter option required
translation from one set to the other at runtime.

Finally the approach I came up with was to get hold of the SOAP body
from Axis and deserialize it myself - directly into my business objects.
Similarly, when sending out a message, I serialized my business objects
directly into the SOAP body of the outgoing message. I have written a
small framework to make all this easy. I am using an XML pull parser to
serialize/deserialize my objects (but any other parsing technology would
do just fine). I am using document-style Web services to do all this.

I would be very interested in your feedback on this approach. Please let
me know if this is a real problem that you are facing too. My framework
code is open source - it is available at http://smfw.sourceforge.net. I
also have two examples that you can run to try out the framework.

Naresh Bhatia

Mime
View raw message