File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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

How to generate Java annotations using Apache Axis

wahed khan

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

Joined: Aug 19, 2005
Posts: 2906
Axis 1.x has no idea about annotations so I wouldn't expect any such support.

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

"Don't succumb to the false authority of a tool or model. There is no substitute for thinking."
Andy Hunt, Pragmatic Thinking & Learning: Refactor Your Wetware p.41
Don't get me started about those stupid light bulbs.
subject: How to generate Java annotations using Apache Axis
Similar Threads
Customising generated JAXB Classes with custom annotations
JAXB and Axis
how to generate Java Annotations using Apache Axis
Axis client and JAXB
JAX-WS - domain model