Popular Posts

Saturday, July 19, 2008

How to use Axis2 codegen ANT task

Apache Axis2 code generator tool provides a very useful custom ANT task. All of the command line code generation options are available with the ANT task as well.
Lets see how a simple client side code generation is done using the ANT task.

Pre-requisites:
Install Apache Axis2 -1.3 or higher
Install Apache ANT-1.7 or higher

Step 1

Create a directory and start to create a build.xml inside that as given below. (eg:- C:\temp\build.xml)

<project name="CodegenExample" default="codegen" basedir=".">

<path id="axis2.classpath">
<fileset dir="C:\axis2\axis2-1.4\lib">
<include name="**/*.jar" />
</fileset>
</path>

<target name="codegen">

<taskdef name="axis2-wsdl2java"
classname="org.apache.axis2.tool.ant.AntCodegenTask"
classpathref="axis2.classpath"/>

<axis2-wsdl2java
wsdlfilename="C:\test\your.wsdl"
output="C:\output" />
</target>

</project>

If you are familiar with ANT, you should be able to understand this simple build script easily. We use the path referenced as "axis2.classpath" to add Axis2 library jars which are placed at AXIS2_HOME/lib (In our example, C:\Axis2\Axis2-1.4\lib)

Axis2 codegen ant task is implemented by the org.apache.axis2.tool.ant.AntCodegenTask class. Therefore we refer to that inside a taskdef as given in "taskdef name="axis2-wsdl2java"

wsdlfilename attribute is equivalent to the -uri option in wsdl2 java command line tool and output is similar to -o option.

Replace the values of wsdlfilename according to your wsdl location.

Step 2
Open a command prompt and go to the directory where you saved the above build.xml.
Type 'ant'

The generated stub classes will be saved in the specified out put directory.

19 comments:

yuvakumarr said...

Hi
Thanks for your nice blog with tips on axis2. I was trying to generate stub classes for mscrm wsdl, using axis2, and followed your sample build.xml. I am getting the following exception...

C:\TEMP\axistest\build.xml:17: org.apache.axis2.wsdl.codegen.CodeGenerationExcep
tion: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException

Could you pl suggest what am I doing wrong here.

Regards

Yuva

Charitha said...

Hi Yuva,
Thanks for your feedback.
Were you able to generate code successfully with wsdl2java.bat tool?
It seems the error is related to your WSDL. if possible, please post your wsdl to uoccharitha@gmail.com

regards
Charitha

yuvakumarr said...

Hi Charitha,

thanks for your reply. No, I am not able to generate the code. I will post the wsdl (2 files) to the email id you have given.

thanks for your help.

Regards

Yuva

yuvakumarr said...

Hi Charitha,

By mistake, I have specified as 2 wsdl files instead of one file. I have sent one WSDL file.

Regards
yuva

Charitha said...

Helo Yuva,
Your wsdl has the following message;
<wsdl:message name="DeleteSoapIn">
<wsdl:part name="entityName" element="tns:entityName" />
<wsdl:part name="id" element="tns:id" /&ht;
</wsdl:message>

As you can see, there are two parts used in this message.
In document style if there are more than one part for the message then
the part to be used should be specified in the binding section.
So, you should modify bindings according to this rule.
e.g:-
<wsdl:input>
<soap:body part="
entityName" use="literal"/>
<soap:header message="tns:DeleteCallerId" part="CallerId" use="literal"/>
</wsdl:input>

yuvakumarr said...

Thanks. I will verify / fix the issue. thanks for your help.

Regards

Yuva

crystal said...

Thank you so much!!polo shirt men'ssweate,Burberry Polo Shirts lacoste sweater, ralph lauren Columbia Jackets,ski clothing. Free Shipping, PayPal Payment. Enjoy your shopping experience on mensclothingus.com.You can find the father who desire fashionable, intellectual mens clothing simultaneously.
http://www.pumafr.com/blog
http://poloshirtsonline.blogspot.com
http://thediary.org/mensclothing
http://blog.livedoor.jp/dokoma
http://www.itimes.com/my_blog.php

crystal said...

Awesome!!!Best wishes for you !!cheap polo shirts is the father of the summer should be prepared to most commonly used item, it has both style and shape of Ralph Lauren Polo, and vest with a random function polo ralph lauren, so that in the short-sleeved apply to both on many occasions, the pink and black color men's polo shirts brought into effect, lightweight cotton, linen texture to demonstrate masculine temperament and sense of fashion exhaustively.

crystal said...

God bless you!I really agree with your opinions.Also,there are some new fashion things here,gillette razor blades.gillette mach3 razor bladesfor men.As for ladies,gillette venus razor blades must the best gift for you in summer,gillette fusion blades are all the best choice for you.
http://gilletterazor.blog.drecom.jp
http://www.getablog.net/ColumbiaJackets
http://crystal888.edublogs.org
http://blog.qlep.com/blog.php/gillette
http://chinaclothes.net

crystal said...

Perfect!!You are a outstanding person!Have you ever wore chaussures puma,Here are the most popular puma CAT,Puma shoes store gives some preview of puma speed cat,and casual but no sweat puma basket.

crystal said...

Do not mean bad.Thank you so much!I just want to show some fashion things to all of you.I like puma speed, puma femmes and other puma shoes. These puma sport items are at store recently and available for anyone.

crystal said...

Fantastic!God bless you!Meanwhile,you can visit my China Wholesale,we have the highest quality but the lowest price fashion products wholesale from China.Here are the most popular China Wholesale productsfor all of you.You can visit http://chinaclothes.net.Also the polo clothing is a great choice for you.
real life
chaussures puma zone
chaussures puma online
polo shirts lj's blog
mensclothingus
ugg boots'camp

srggy said...

The larger that the head size is for your babolat pure drive, the more power you will be provided with. Additionally, a larger wilson k six size means a larger sweet spot which is why beginners as well as intermediate players often prefer to work with a head microgel with a larger head size. Additionally, thicker frames are also capable of generating more power as well. Smaller head sizes on prince-o3-tour on the other hand are capable of providing less power, but significantly more control cheap tennis racquets.new polos men poloswomen polosdiscount polossummer polospolo shirts whosalepolo fashionembroodered polostennis racketsclothing poloclothingedhardyshirtedhardyclothingsummer ed hardy clothingcheap shirtsed hardy brand.

srggy said...

Although many people criticize ed hardy clothing for having nothing but tattoo patterns, being filled with waste and useless things, it is widely acknowledged that ed hardy clothes draws the most attention of both common young people as well as many Hollywood welcomed stars for its punk ed hardy t-shirts rock styles. As a matter of fact, in such a world where all ed hardy shirts are much like each other, ed hardy mens creates yet another totally new global sensation in fashion crowd for ed hardy womens fancy design. An increasing number of people are charmed by the magic of amazing tattoo and impressive color of ed hardy sunglasses.

srggy said...

In this version of the ralph lauren polo, the styling and fabric is advertised as being made out of "playdry" material. Burberry Polo Shirts is another performance fabric which is intended to add luxury Cheap polo shirts, coolness, and moisture wicking qualities. Performance fabrics wholesale polo shirtswere originally created primarily for athletes and other sports enthusiasts who work up a good sweat ralph lauren polo shirts. The moisture wicking fabric in cheap ralph lauren polos draws the moisture away from the body which then evaporates quickly discount ralph lauren polos. ralphlaurenpoloshirts keep the body cooler and drier even when the athlete is under physical duress polo clothing.

srggy said...

polo ralph lauren RED! Series of design criteria - stylish, simple, self-cultivation. For the first time in 2009 in New York Fashion Week debut, RED! Series has a new Polo Shirts On Sale series from the traditional burberry polos LOGO, LOGO traditional crocodile logo at the Ralph Lauren Polo Shirts letter above, and the new series of letters with the cheappolos logo in line to be between a red symbol of Burberry Polo Shirts.

swimingfidh said...

Come here to have a look of our Wholesale Jeans
Many fashionMens Jeans ,eye-catching
Womens Jeans ,and special out standing
Blue Jeans ,you can spend less money on our
Discount Jeans but gain really fine jeans, absolutely a great bargain.
www.crazypurchase.com
China Wholesale
wholesale from china
buy products wholesale
China Wholesalers
http://www.weddingdressseason.com

swimingfidh said...

There are ed hardy shirts
,pretty ed hardy shirt for men,

ed hardy womens in the ed hardy online store

designed by ed hardy ,
many cheap ed hardy shirt ,glasses,caps,trouers ed hardy shirts on sale ,

You can go to edhardyshirts.com to have a look ,you may find one of ed hardy clothing fit for you
Top qualitymen's jacket,
These cheap jacket are on sale now,you can find
north face jackets inmage on our web
Ralph Lauren Polo Shirtsbuberry polo shirts

Do you wannaghd hair straighteners for you own , we have many
cheap ghd hair straightenersin style and great,you can choose one from these
hair straighteners
Authentic chaussure puma
chaussure sport
And chaussure nike shoes

stamatis said...

Hello,

I use the org.apache.axis2.tool.ant.AntCodegenTask to produce the server and client side of my service. Everything worked fine with SUN's JDK.

But when I tried to change to IBM's JDK(Java(TM) SE Runtime Environment (build pwi3260sr8fp1-20100624_01(SR8 FP1))) it does not create some of the getters/setters of my objects and build breaks.

Have you ever faced such a problem?

Thanks