Results 1 to 2 of 2
  1. #1
    kievari is offline Member
    Join Date
    Nov 2009
    Rep Power

    Default xml to database from xml rpc

    I am new to java and want to test an idea, to get data from mysql server online and insert it to a local derby database by java. I successfully completed a client that gets data from a Joomla! site, using XML-RPC, and riches to this point:

    Java Code:
    Object[] params = new Object[]{new Double(4.0), new Double(5.0)};
    Object result = client.execute( "foobar.add", params );
    The "result" variable contains this xml data:
    Java Code:
    <params> <param> 
    <member><name>value1</name> <value><double>4.2</double></value> </member> 
    <member><name>value2</name> <value><double>9.6</double></value> </member> 
    <member><name>product</name> <value><double>13.8</double></value> </member> 
    </param> </params> 
    I have also my derby database created and set up correctly. The last thing I need to know is, having this data in the "result" variable, and supposing the existence of a table with "value1", "value2" and "product", how can I insert the data from result to this table?
    I searched the forum, also google, but there are various tools and nothing seems to be very sophisticated. I thing there must be a simple way, by using some tool that simply extracts such fields' data from "result" and using sql writes it back to the database.

    Could you guide me toward such a device?

    Thank you! :)
    Last edited by kievari; 11-19-2009 at 05:24 PM.

  2. #2
    FON is offline Senior Member
    Join Date
    Dec 2009
    Belgrade, Serbia
    Rep Power


    Your problem has web service nature.

    Your are invoking some remote operation on some server, send params to it,
    and get response in client that has to be stored in DB.

    Your use case is typical, but your solution is not. Why?

    First thing you have to be aware of is : in what format is data send back to you.

    You have to know exactly signature of operations on server side
    and if this is about web services you can take WSDL file from server that describes those operations,
    and put it into some Web Sevice Wizard (any Eclipse IDE J2EE version) to automatically create client code structure, that communicates with web service server on RPC bases.

    What you have in your code is totally generic because you have Object type:

    " Object result = client.execute( "foobar.add", params ); "

    If this object can be casted to your own POJO classes that can be easily stored
    to DB using DAO or some ORM (like Hibernate...), You must consider 2 things here :

    Why would you directly store data from XML to DB and what you are about to create first: DB table model and reverse engineer it with some tool to create 1: 1 Java class entities or vice versa?

    You have to consider data validation that comes from outside in you app too.

    So this is not just about skiping and avoiding cubersome code writing,
    you WILL NEED java classes that represent tables in DB.

    In some other cases in you just need to store massive amount of data from one DB to another without any data type conversion or validation,
    you can use many tools, play around with easy local *.csv import/export that is very fast and supported from all major RMDB systems.

    i hope this is not too much info for you,
    i suggest you should spend some time on learning java web services

    regards :)

Similar Threads

  1. Database Help
    By simtology in forum New To Java
    Replies: 3
    Last Post: 08-18-2009, 03:03 PM
  2. Database Help
    By simtology in forum New To Java
    Replies: 1
    Last Post: 08-17-2009, 06:14 PM
  3. database
    By kswiss in forum AWT / Swing
    Replies: 0
    Last Post: 03-26-2009, 11:51 AM
  4. Replies: 2
    Last Post: 02-11-2009, 04:43 AM
  5. Database in a PDA
    By percivalwcy in forum JDBC
    Replies: 2
    Last Post: 08-08-2007, 03:10 AM

Posting Permissions

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