wsdl2java usage

I have been using wsdl2java command for long time. I feel I need to record this information somewhere even though there are tons of information related to this. So below is for my own reference.

ComplexType object in the WebService, specially, inheritance happened in the WebService, we must use simple Stub and many classes generation.  In general, there are 2 ways of generating consumer.

1. One complex Stub class with inner classes
2. One simple Stub class with complex type classes
Personally, I think one complex Stub class is better because it is easy to maintain and cleaner. I will explain two different WSDL2Java scripts. We can call script or directly execute WSDL2Java.bat file in Axis1-1.3/bin folder.

One Complex Stub (Preferred method)
CMNprfService.wsdl package : com.abs.cro

[USR:DEV] msjo@HY126045 $ wsdl2java.bat -o C:/temp/gen
-uri eiservices.wsdl -d adb -sp -s -p com.abs.usr.webservice.dcm
Using AXIS2_HOME: C:\DevApps\axis2-1.6.2Using 
JAVA_HOME:        c:/bea103/jrockit81sp6_142_10
[USR:DEV] msjo@HY126045 $

-o C:/temp/gen indicate output location
-uri location and name of WSDL. I generated locally. Not like Axis1.1, WSDL should be copied locally in order to generate java classes. I think it is because of axis2 architecture changes. As you can see there is no parameter for userid and password.
-d adb Axis Databinding is default. There are 2 other ways to generate java classes, but this way is the simplest and easiest way.
-sp Suppress namespace prefix. To simplify SOAP request/response object.
-s Synchronous call stub only (if you don’t specify -s or generate with -a another class called a CallbackHandler will be generated)
-p specify the package name, so you don’t need to change it later

Simple Stub and many classes

[USR:DEV] msjo@HY126045 $ wsdl2java.bat -o C:/temp/adbAll
-uri CmDcmService.wsdl -g -ss -d adb -p abs.usr.webservices.dcm
Using AXIS2_HOME: C:\DevApps\axis2-1.6.2Using 
JAVA_HOME:        c:/bea103/jrockit81sp6_142_10
[USR:DEV] msjo@HY126045 $

-g generate all classes
-ss generate serverside code


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s