This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Web Services and the fly likes Best Practices for xsd to Java, when both are already defined Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Best Practices for xsd to Java, when both are already defined" Watch "Best Practices for xsd to Java, when both are already defined" New topic
Author

Best Practices for xsd to Java, when both are already defined

Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

So we have a Java Object Model for our orders, and there is an XSD (we call is a CDM) for transferring the Order to Oracle Financials. So our object model doesn't match the Oracle model. Both are already defined. I want to find the best way to convert our Order object to a SOAP message to the Web Service that expects the XML to be in the xsd format.

Any suggestions?

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Reid M. Pinchback
Ranch Hand

Joined: Jan 25, 2002
Posts: 775
When both endpoints already exist you are pretty much stuck doing a transformation. The transform could be at the XML point (via XSLT) or in Java at one end (traversal of the object tree to create a different object tree), followed by a cleaner XML serialization/deserialization (JAXB or XMLBeans). If througput matters (large volumes of smaller documents), I'd be more inclined towards the latter approach. Bottom line: impedence mismatch is a pain.


Reid - SCJP2 (April 2002)
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Thanks Reid.

Those were basically the two options that I have been weighting, while also looking at Castor XML to write a mapping file that maps the Object to the XSD. The only thing with that one is any Castor overhead, and trying to find xdoclet tags that we can include in the object that will automatically generate the mapping files for us.

Mark
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Still looking to see if there are any more suggestions.

Also, there are methods in our Domain Object to convert the Object to the XML. I am most likely going to move those methods out of the domain object and into a Decorator/Wrapper object.

Mark
[ January 24, 2006: Message edited by: Mark Spritzler ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Best Practices for xsd to Java, when both are already defined
 
Similar Threads
XML Parsers
XML and Object already defined. JAXB type questions
Java, J2EE, Swing/SWT Developer (Work From Home)
XML and Java Classes
How to change user credentials when accessing DB