One of the ways to create client stubs in Java is through XML schema. Once we have server side artifacts, we can generate fully annotated Java classes from an XML schema file by using the JAXB schema compiler, i.e. xjc command-line tool. The resulting JAXB objects/Java Stubs can be used in Java applications to manipulate the XML request and response data.
Steps to follow:
1. Copy the XML schema to a file <schema-fileName>.xsd in <source-directory>. Or create XSD schema for web service with .xsd.
2. From <source-directory>, use following command to create java stubs from that xsd
xjc <source-directory>\<schema-fileName>.xsd -p <destination-package> -d <destination-directory>
3. Use the generated JAXB objects within your Java application to manipulate XML content through the generated JAXB classes.
4. Use following command to compile and generate .class files
javac -d <directory-for-classFiles> <destination-directory>\*.java
5. Now to have .jar file for these generated stubs, we can use following command
cd <directory-for-classFiles>
jar cvf <jar-filename>.jar
6. Copy .jar file in lib folder of your application for further access.
Steps to follow:
1. Copy the XML schema to a file <schema-fileName>.xsd in <source-directory>. Or create XSD schema for web service with .xsd.
2. From <source-directory>, use following command to create java stubs from that xsd
xjc <source-directory>\<schema-fileName>.xsd -p <destination-package> -d <destination-directory>
3. Use the generated JAXB objects within your Java application to manipulate XML content through the generated JAXB classes.
4. Use following command to compile and generate .class files
javac -d <directory-for-classFiles> <destination-directory>\*.java
5. Now to have .jar file for these generated stubs, we can use following command
cd <directory-for-classFiles>
jar cvf <jar-filename>.jar
6. Copy .jar file in lib folder of your application for further access.