Announcement Announcement Module
Collapse
No announcement yet.
Converting from POJO to XML? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #2
    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...

    Comment


    • #3
      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

      Comment


      • #4
        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.

        Comment


        • #5
          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

          Comment


          • #6
            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.

            Comment


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

              Ben

              Comment


              • #8
                or...

                Or maybe a shovel vs. a spoon?

                Comment


                • #9
                  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.

                  Comment


                  • #10
                    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.

                    Comment

                    Working...
                    X