Axis is an engine to create web services. It has implementations in Java and C. In this post we will see how to create Axis web service as java project with IntelliJ IDEA version 14.
Last stable release of Axis was produced in April 2006. Now Axis replaced by Axis2. Axis2 has more features and it is certainly recommended to use Axis2, not Axis. I will write about Axis2 later. When I needed to create Axis2 web service, I started with Axis, because it is easier to understand the principle with special plugin for IntelliJ. There is plugin for Axis2 too, but it is not compatible with IntelliJ IDEA 14.
We will create both sides: service and client. This post is about create service side.
What do you need:
– IntelliJ IDEA
Create project (“File”->”New”->”Project…”). In dialog window select from left column Java Enterprise. Select Tomcat as Application Server. If there is no configured Tomcat, press “New” and set path to Tomcat. You can download Tomcat version 8 here.
From “Additional Libraries and Frameworks” select WebServices. Use generate sample server code block. IntelliJ can download library, but I prefer to download and set library manually. You can download Axis library from here.
Your dialog window should look like in screenshot below.
Press “Next”. Set the name of the project.
Automatically generated directories and files:
Then we need to configure library of artifact. Click “Build”->”Build artifacts…”. In appeared dialog window click “Edit…”. Add Axis library to WEB-INF/lib folder (you can just click on “Fix” in the bottom of dialog window). In picture below JAX-WS is Axis library:
Add “@WebService” and “@WebMethod” into HelloWorld like in picture below:
Compile this file by pressing “Ctrl”+”F9”.
Click on HelloWorld file. Select “Tools”->”Web Services”->”Generate Wsdl From Java Code…”. Dialog window appears, where you can define several parameters, choose web functions.
We just need to click OK. After that HelloWorld.wsdl file have to be generated in directory where HelloWorld.java located.
Note: Please pay attention to Arda’s comment:
Our service is ready. Press “Shift”+”F10”.
If everything OK and you didn’t change default running options, new tab should appear in internet browser. Type “http://localhost:8080/services” (8080 is port of Tomcat, your Tomcat port number may be different). In this page you can see the list of installed services:
If you see HelloWorld (wsdl), everything is OK. Great! We’ve done creating sample Axis service on java.