By Jeffrey Rubinoff on Feb 26, 2008
Step 1: Download and install Axis 2. Well, that's easy enough, it's just a ZIP file. I see there is also a WAR file that I can download, but Step 2 is building the WAR file, so let's follow the engineer's directions and just download the zip and unzip it somewhere, say C:/ root.
Step 2: Run the build script in the Axis2/webapp directory to create axis2.war. Splendid, although there is no build script, just a build.xml. Wait, if there is a build.xml, then I can build it with ANT. Do I have ANT on my classpath? ... Nope. Have I installed ANT? ... Evidently not. So I install Jakarta ANT, put it on my PATH, and Bob's your uncle, or my uncle, or something. I wish I could write "...and Bob's your uncle" in an official tutorial. Anyway, ANT runs and I get my axis2.war file.
Step 3: Copy axis2.war to the J2EE server webapps directory. I copy it both to TOMCAT_HOME/webapps and GLASSFISH_HOME/domains/domain1/autodeploy.
Step 4: Start IDE.
Step 5: Install the Axis2 nbm plugin file. Milan sent me one as an email attachment, but the 6.1 distro I installed already had it as an available plugin, so that was easy.
Step 6: Go to Tools -> Options -> Axis2 -> Runtime and type in the Axis home directory. Easy enough.
Step 7: Still in the Axis2 Options, switch to the Deployment tab and enter the path either to the Tomcat Axis2.war or the GlassFish Axis2.war. I choose Tomcat since Axis is supposed to work a little better on that server. Milan's advise was to enter the path to the TOMCAT_HOME/webapps/axis2 directory, to which Tomcat unpacks the WAR, rather than the WAR file itself. However, I couldn't find an axis2 directory so just typed in the path to the WAR. Later I found out the significance of this absence...
Step 8: Enter the Tomcat Manager username and password. Fine, except that first I have to find out what they are. Milan said that they are in TOMCAT_HOME/conf/tomcat-users.xml, and he sent me an example of the file. It's a good thing he did, because my tomcat-users.xml is empty. I copy Milan's file into mine, and now I have Manager username "tomcat," password "tomcat."
Step 9: Create a new Java Library project. OK, I name it AxisBoldAsLove. Note to self: Do not make Jimi Hendrix references in official Sun tutorials. I create a myaxis package in the project.
Step 10: Create an empty Axis web service from Java in the project. I choose New -> Other -> Web Services -> Axis2 Service from Java and select "Empty Web Service" from the wizard. I put it in the myaxis package. Well, hurrah! I get an Axis Web Services tab in my project, with the NewAxisFromJava WS (hmmm, I should have selected a name), and the NewAxisFromJava.java class in my source package. Terrible name.
Step 11: Implement the service class. Well heck, I can't open the Axis web service, so I guess I should change the .java class. That however already has some "Hello, World!" output specified by default. Maybe I don't need to implement anything?
Step 12: Deploy the service. I right-click the service and select Deploy... OK, I get a BUILD SUCCESSFUL message, but nothing on the Tomcat log. That doesn't seem right.
Step 13: Check that service is at http://localhost:8080/axis2/services. Er, I have a 404 error.
OK, Milan's gone but Lukas Jungmann listens to my woes. We go through my project. And here's the nub: I should have copied axis2.war to the Catalina base, which is in Documents and Settings/Jeff/.netbeans, not to TOMCAT_HOME. Well, bloody hell, I copy it to CATALINA_BASE.
Still a 404 error! Lukas scries my log and sees that when I redeploy the WAR file, I'm still redeploying the one in TOMCAT_HOME. So we look at Tools -> Options -> Axis2, and sure enough, it's still pointing to the TOMCAT_HOME WAR file. So I change that, redeploy the service and generate a WSDL file.
Success at last! Everything is where it's supposed to be, and a JAX-WS client can be created based on the WSDL file.
Well, dear reader, by the time you see my tutorial this process should be simplified somewhat. Step 6 is already obsolete, because Milan has received permission to include the Axis libraries directly in our plugin. I'll try to play around with the service code a bit to see if I can make it do anything interesting, but really there's not much to it. All the operations appear to take place in a standard Java class, and that class is then exposed as an Axis web service. To change the operations, you change the java class and these changes are automatically reflected in the Axis web service. Milan's added subnode display to the web service in the project, so you can watch the operations get added to the web service in real time! After changing the service, you of course have to redeploy it, and then whoever is running the client has to refresh it.