Results 1 to 10 of 10

Thread: Converting from POJO to XML?

  1. #1

    Default Converting from POJO to XML?

    We have a complex domain model for our project and we are thinking about making certain functions available using webservices...
    So I was just wondering if anyone knew of any application we can use to convert our object (containing Set, List, etc) into xml that the webservice can use?


    Regards,

    BTJ
    Someone wrote:
    "I understand that if you play a Windows CD backwards you hear strange Satanic messages"
    To which someone replied:
    "It's even worse than that; play it forwards and it installs Windows"

  2. #2
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    The general term for it is XML marshalling or XML binding, and there are a lot of tools which can do that: JAXB, Castor, JIBX, XMLBeans...
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

  3. #3

    Default

    Quote Originally Posted by poutsma
    The general term for it is XML marshalling or XML binding, and there are a lot of tools which can do that: JAXB, Castor, JIBX, XMLBeans...
    I have looked at most of them, but they don't seem to be able to convert other than ordinary types (not List and Sets, etc) or am I mistaken?

    BTJ
    Someone wrote:
    "I understand that if you play a Windows CD backwards you hear strange Satanic messages"
    To which someone replied:
    "It's even worse than that; play it forwards and it installs Windows"

  4. #4
    Join Date
    Oct 2006
    Posts
    2

    Default

    Quote Originally Posted by bjorntj View Post
    I have looked at most of them, but they don't seem to be able to convert other than ordinary types (not List and Sets, etc) or am I mistaken?

    BTJ
    In my experience, these frameworks have no problems with List types.

  5. #5
    Join Date
    Feb 2006
    Posts
    164

    Default

    This is my experience as well, i.e. no problem in this regard using both JAXB and Castor. They eliminate a LOT of the grunt work. In the "old days" we had to do all the grunt work using the DOM api.

    Ben

  6. #6
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    Quote Originally Posted by benethridge View Post
    This is my experience as well, i.e. no problem in this regard using both JAXB and Castor. They eliminate a LOT of the grunt work. In the "old days" we had to do all the grunt work using the DOM api.
    Well, there are some finesses you can't express with XML marshalling solutions. Java and XML are different beans, just as Java and SQL are. Sometimes, it makes more sense to use JDBC instead of Hibernate, and sometimes, it makes more sense to use DOM instead of JAXB.
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

  7. #7
    Join Date
    Feb 2006
    Posts
    164

    Default

    I agree. Like using a chain saw versus a Dremel scroll saw. Both good tools, if used as intended.

    Ben

  8. #8
    Join Date
    Jun 2006
    Location
    outside boston
    Posts
    108

    Default or...

    Or maybe a shovel vs. a spoon?

  9. #9
    Join Date
    Jan 2005
    Location
    Wellington, New Zealand
    Posts
    17

    Default

    I'm not sure if it will work via WS, but you can try Apache Betwixt (http://jakarta.apache.org/commons/betwixt/). This will makes easy work of transforming pojo's to xml.

  10. #10
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    It looks like Betwixt doesn't have any XSD schema support. This makes it less usable for doing web services, similar to XStream, for instance.

    Not that I don't like these approaches, there just are less suitable for WS.
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •