Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2007

Tip: Looking for answers? Try searching our database.

XML string to Java Object...

Thread view: 
Bogus Exception - 21 Mar 2007 07:18 GMT
It would seem simple, but it is proving difficult to find an example
that takes XML from a web service and creates java objects from it.
Given the output of the web service:

<Commands xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <Name>The Name</Name>
 <Command>The Command</Command>
</Commands>

I just need to make objects of type:

public class Commands {
    static final long serialVersionUID = 1;
    public String Name;
    public String Command;
}

TIA!
voorth - 21 Mar 2007 10:34 GMT
On Mar 21, 7:18 am, "Bogus Exception" <bogusexcept...@gmail.com>
wrote:
> It would seem simple, but it is proving difficult to find an example
> that takes XML from a web service and creates java objects from it.
[quoted text clipped - 16 lines]
>
> TIA!

If you don't mind using a 3rd party lib, I would recommend Castor:
http://castor.codehaus.org/

It gives you the possibility of generating classes from XML schema's,
or ,if you already have your classes, to use a mapping. I've found
the  maintainers very helpful if you have problems getting started.

Henk
Lew - 21 Mar 2007 13:56 GMT
> On Mar 21, 7:18 am, "Bogus Exception" <bogusexcept...@gmail.com>
> wrote:
[quoted text clipped - 16 lines]
>>
>> }

If you use Apache Axis, there is the WSDL2Java tool. The project's
documentation is the place to look for examples.

-- Lew
Bogus Exception - 24 Mar 2007 13:21 GMT
Hmm.. I posted a reply, but it never made it to the group.. For those
who helped, and those others interested, I posted the reply where it
couldn't be blocked/filtered:

http://atcp.us/blog/2007/03/22/deserialization-of-vbnet-object-via-j2ee-web-serv
ice-using-xstream/


Thanks!

> > On Mar 21, 7:18 am, "Bogus Exception" <bogusexcept...@gmail.com>
> > wrote:
[quoted text clipped - 21 lines]
>
> -- Lew


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.