Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to genrate classes from xsd?

 
swarupa patil
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can also use XmlBeans from appache http://xmlbeans.apache.org/.
 
chandrahas nelapatla
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Which one is better whether to use XMLBeans or JAXB. What is the difference between the two.
regards
sudha
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic