aspose file tools*
The moose likes Web Services and the fly likes How to genrate classes from xsd? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "How to genrate classes from xsd?" Watch "How to genrate classes from xsd?" New topic
Author

How to genrate classes from xsd?

swarupa patil
Ranch Hand

Joined: Feb 22, 2006
Posts: 62
Hi
I am new to web service technology.
I want to know how to generate the java classes from
XSD.
Which tools are used for web service operations?
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Originally posted by swarupa patil:
Which tools are used for web service operations?


When dealing with SOAP based web services you need a WSDL to create a stub with a WSDL2Java compiler.
The WSDL refers to XML Schemas but the schemas themselves are not enough.
What that WSDL2Java compiler is called depends on the web service toolkit that you are using.

I want to know how to generate the java classes from XSD.


Now if you are simply retrieving an XML document over an HTTP connection then you can use JAXB to do the (un)marshalling.

With the JVM 1.4 you can use JAXB 1.0.x
JAXB 1.0 tutorial
Chapter 1: Binding XML Schema to Java Classes with JAXB
Chapter 2: Using JAXB

With the JVM 1.5 you can use JAXB 2
JAXB 2.0 tutorial
Binding between XML Schema and Java Classes
rsg
Greenhorn

Joined: Oct 01, 2007
Posts: 4
You can also use XmlBeans from appache http://xmlbeans.apache.org/.
chandrahas nelapatla
Greenhorn

Joined: Oct 04, 2007
Posts: 2
You can use XMLbeans. to use this you need to download from http://download.nextag.com/apache/xmlbeans/binaries/

you can download xmlbeans-2.3.0.zip

once you download you need to place your xsd in the bin of the extract and run scomp -out jarname.jar xsdname.xsd (make sure that you point the scomp to the java home by editing it)

a jar will be generated in the bin. add this jar and the lib jars from the extract to your class path. the jar will contain class for the XSD
sudha swami
Ranch Hand

Joined: Apr 24, 2007
Posts: 179
Hi,
Which one is better whether to use XMLBeans or JAXB. What is the difference between the two.
regards
sudha
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Originally posted by sudha swami:
Which one is better whether to use XMLBeans or JAXB. What is the difference between the two.


JAXB is part of the standard Java distribution starting with Java SE 6 and Java EE 5. XmlBeans is an open source project that predates JAXB - it will always be separate and never be part of the standard Java distribution.

JAXB 1.0 requires Java 1.4. JAXB 2.0 requires Java 1.5. Some XmlBeans versions probably work with pre-1.4.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to genrate classes from xsd?