Today I want to show You how to configure and run simple application with WebService using Axis2 and Rampart. In this series of tutorials i will show you how to create client for this WS and implements JAX-RS. Basic configuration of JAX-WS is very simple. So i try to conifgure very popular module Axis2 with Rampart. Source code of this application You can download from AxisRampartExample. So lets begin.
Frist step is to configure pom.xml file. It contains all needed dependencies for using Rampart, Axis2 and JAX-RS . This pom.xml also contains plugin to generate wsdl files and generate source code from wsdl file.
First, we comment plugins that generates or use wsdl files. We use them later. That plugin are: axis2-java2wsdl-maven-plugin and axis2-wsdl2code-maven-plugin. I want be describe every part of pom.xml file. You can find information about maven on any other sites.
Creating WebService in Axis2
Next step, we create class that will be represents our WebServices. In this example this class will be: pl.lgwozniak.MyService.java . This is simple class with one plain methods.
Now Axis2 need to now that this class will be WebService. For that we need to create file service.xml in path: /src/main/webapp/WEB-INF/services/WebServices/META-INF/services.xml . Example of how we configure webservice in Axis2 is below :
Now a little description. Tag module tell axis that we want to use module rampart. Tag parameter with name InflowSecurity tell axis what type of authorization we want to use. In our case it will be UsernameToken. We need to give passwordCallbackClass for axis authorization. Example of this class You can find below:
The most important information here is in line 29. I spent many hours to find that you can’t check password here like in the version 1.4 of axis2. In new version of 1.6 ( maybe even in 1.5) you need to give axis2 a pasword in callback class. I think it isn’t good idea, because it is hard to implements authorization in that way in more complex application. So, We offen use version 1.4 of that library.
In next part we describe how to implements client version for that WebService.