Overview
Application Scenario
When using a web service as a data source for your project, you may want reports to directly call the web service instead of defining a data connection to use the corresponding database table. This document describes how to implement this.
Implementation Method
You can use the Java program to access the web service, convert the data returned by the web service into a class dataset, and then use the dataset in the designer. In this example, the web service data source is published from a JWS file and accessed directly.
Example
In an Axis 1.4 project, publish a web service from a JWS file. Then use Java code to send a Simple Object Access Protocol (SOAP) request to the web service and retrieve the data.
Preparing the Web Service Data Source
Preparing the Axis Server
If you have set up an Axis server, skip this step.
1. Download and install the Java Development Kit (JDK) and a web application server to set up the deployment environment. This example uses Tomcat, which has been set up in advance.
2. Download the deployment package (axis-bin-1_4.zip in this example) from the Axis official website, extract the package, copy webapps/axis to the Tomcat installation directory/webapps path, and start Tomcat. If you can access the Axis service via a URL in a browser, the deployment is successful. This example uses a local server, so enter http://localhost:8080/axis/ in the browser. If the Apache-AXIS page is displayed, the deployment is successful.

Publishing a Web Service
Publish a web service from a JWS file named TestWS2TDClient.jws in the Axis project under Tomcat. The service returns array data.
1. Create a TestWS2TDClient.java file with the following content:
public class TestWS2TDClient {
public String[][] getTD() {
String[][] a = { { "City", "Salesperson", "Sales" }, { "New York", "Anna", "230" }, { "Los Angeles", "Alex", "190" },
{ "Chicago", "Jack", "320" }, { "Houston", "Kate", "210" }, { "Phoenix", "Faye", "150" }, { "Seattle", "Sammi", "280" } };
return a;
}
}
2. Rename TestWS2TDClient.java to TestWS2TDClient.jws, set the encoding format to GBK, and place the file under Tomcat installation directory/webapps/axis/. In this way, the sample data is published as a web service, as shown in the following figure.

3. Access http://localhost:8080/axis/TestWS2TDClient.jws in the browser, as shown in the following figure.

Click Click to see the WSDL. If the Web Services Description Language (WSDL) content is displayed, the service is published successfully, as shown in the following figure.
Note: 
Defining a Class Data Source
The web service data source has been prepared in the "Preparing the Web Service Data Source" section. Next, use Java to send a SOAP request to access the TestWS2TDClient.jws web service and retrieve the data. Then, define the WebServiceTableData.java class that extends SimpleTableData, and convert the obtained array data into a class dataset.
Preparing the Compilation Environment
Before compiling the program, you need to create a Java project environment and prepare a Java editor (for example, Eclipse or IntelliJ IDEA).
Import the JAR files of your FineReport project into the editor. The JAR files include:
All files in FineReport installation directory/lib
All files in FineReport installation directory/server/lib
All files in FineReport installation directory/webapps/webroot/WEB-INF/lib
tools.jar in JDK installation directory/lib
JAR files in Axis installation directory/WEB-INF/lib
For details, see Compiling a Java Program.
Writing the Java Program
Use Java to send a SOAP request to access the TestWS2TDClient.jws web service and retrieve the data. The code is as follows:
Note: try {
String endpoint = "http://localhost:8080/axis/TestWS2TDClient.jws";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName(new QName("http://localhost:8080/axis/TestWS2TDClient.jws",
"getTD"));
String[][] ret = (String[][])call.invoke(new Object[] {});
return ret;
} catch (Exception e) {
e.printStackTrace();
}
After the web service is called, the service returns data to the client. In this example, a string array is returned. Create the WebServiceTableData.java class that extends SimpleTableData, and convert the obtained array data into a class dataset.
You can click to download the complete code: WebServiceTableData.java.zip
Compiling the Java File
After writing the Java program, compile WebServiceTableData.java with the Java compiler. After compilation succeeds, the WebServiceTableData.class file is generated in the output directory of the corresponding project, as shown in the following figure.

Copy the compiled WebServiceTableData.class file to FineReport installation directory/webapps/webroot/WEB-INF/classes/com/fr/data, as shown in the following figure.
Note: 
Creating a Class Dataset
Copy the JAR files in Axis installation directory/WEB-INF/lib to FineReport installation directory/webapps/webroot/WEB-INF/lib of the report project, excluding log4j-1.2.8.jar because it causes a conflict. After the files are copied, restart the report project so that the third-party JAR files can be loaded.
2. Create a template, click the
icon above Template Dataset, select Class to open the Class Dataset window, and select the required class file.

After selecting the class file, click OK to complete the class dataset configuration.
Using the Class Dataset
After the class dataset is configured, drag data columns to cells to bind the data, as you do with other datasets, as shown in the following figure.
Note: 