I. Overview
In this article, we'll deploy an Axis2 service, publish a background WebService to extract data from databases using the aar method, and call the WebService via class datasets.
II. Deployment
1. Download axis2.war
Download the War package from the Axis2 Official Page.
2. Install axis2.war
Unzip the downloaded axis2.war and move all its content into %Tomcat_Home%\webapps. Restart the Tomcat server and a folder named axis2 will be created automatically under this directory.
3. Verify the Deployment
Go to localhost:8080/axis2/, and you will see a page as below if the deployment is successful.
Note: configure the port according to Tomcat port settings.
III. Develop the JDBC Data Extraction Class
The implementation of the class is simple. Just provide a get() method for the client to call the WebService. Note that the database driver should be placed in %Tomcat_Home%\webapps\axis2\WEB-INF\lib. Please go to the following URL for the complete code script: https://github.com/finereport-overseas/example/blob/release/10.0/src/main/java/service/MyService.java
IV. Publish the WebService
1. Create services.xml
Use the following codes for services.xml.
<service name="myService"> <!--name can be customized-->
<description>
Web Service
</description>
<parameter name="ServiceClass">
service.MyService <!--package & class name-->
</parameter>
<operation name="get" > <!--method name-->
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</operation>
</service>
2. Create the Service Class
1) Create a folder WS with two subfolders, namely, META-INF and service.
2) Place the services.xml file into META-INF.
3) Put in the created JDBC data extraction class MyService.class into service.
3. Generate .aar
Use the cd command in Windows Console to enter the WS directory, and type in the following commands to generate the .aar file:
jar cvf ws.aar .
4. Publish WebService
Copy and paste the ws.arr file generated from the previous step into %Tomcat_Home%\webapps\axis2\WEB-INF\services. Start the Tomcat server to call this WebService.
Note: error messages might prompt during the start-up process. This could happen if the names of packages, classes, methods or files are mismatched, and can be resolved by closely checking and correcting.
Once published, the following page will be shown.
V. Class Dataset
1. Import Dependency
Load all the JARs under %AXIS_HOME%/WEB-INF/lib, as well as those related to FineReport into the IDE.
2. Code and Test
Please refer to the following URL for details: https://github.com/finereport-overseas/example/blob/release/10.0/src/main/java/com/fr/data/WebServiceWSDLDataDemo.java
Place the compiled WebServiceWSDLDataDemo.class file into %FR_HOME%/webapps/webroot/WEB-INF/classes/com/fr/data.
3. Use the Class Dataset
Put Axis2-related dependent JARs (except log4j JARs) into %FR_HOME%/webapps/webroot/WEB-INF/lib.
Select and use the class dataset in FineReport.