File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes How to generate Java annotations using Apache Axis 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 generate Java annotations using Apache Axis" Watch "How to generate Java annotations using Apache Axis" New topic
Author

How to generate Java annotations using Apache Axis

wahed khan
Greenhorn

Joined: Nov 09, 2007
Posts: 3
Using Apache Axis iam doing wsdl2java (my wsdl have xsd reference).
I am able to generate the stubs, skeletons, serializable java beans.

I receive input as java objects and need to marshall them into XML that is to be passed to some other application.

I am using JAXB to do marhsalling of java objects to XML.

JAXB requires that the java beans must have annotations @XmlElement(name="fieldName")

The java beans that are generated using Axis doesn't have annotations.
Is there a way by which i can get annotations for the java beans generated through Axis?
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Axis 1.x has no idea about annotations so I wouldn't expect any such support.
http://www.google.com/search?q=annotations+site%3Aws.apache.org%2Faxis

With Axis2 JAXB 2.0 RI (and JaxMe 2) support is still experimental. WSDL2Code databinding support is limited to ADB (Axis2 Data Binding), XmlBeans and JiBX. So again I wouldn't expect that kind of support.
Command Line Version Option reference

Originally posted by wahed khan:
JAXB requires that the java beans must have annotations @XmlElement(name="fieldName")


As far as I recall that annotation is only important if you intend to generate an XML Schema from your Java Classes. The fact that you are using a WSDL indicates that you already have an XML Schema (that schema may be contained within the WSDL) - so JAXB will generate the marshaller and unmarshaller classes from that. If the annotation is important then JAXB xjc will add it during the XML Schema-to-Java code generation. You are most likely using a WSDL2Java that isn't JAXB aware.

If you are using Axis 1.x then the most likely route is to stop using its WSDL2Java tool and configure the web service endpoint for the Message service style and use the JAXB (un)marshallers on the SOAP request/response payload.
Anne Thomas Manes: Why you might want to use Axis Message Style

Unofficial JAXB guide
Java EE 5 Tutorial: Chapter 17 Binding between XML Schema and Java Classes
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to generate Java annotations using Apache Axis