I. Preparation
1. Load JARs Under the Project
If custom development on FineReport designer is needed, the first and foremost thing is to load JARs from the FineReport designer. Please refer to Start the Designer in Eclipse for details.
2. Load Third Party JARs Under the Project
JARs under %AXIS_HOME%/WEB-INF/lib should be loaded into Eclipse as well. Please refer to Start the Designer in Eclipse for details.
3. Load Third Party JARs Under the Report Environment
When the local FineReport designer connects to class datasets, JARs (log4j-1.2.8.jar need to be excluded to avoid conflicts) under %AXIS_HOME%/web-inf/lib should be copied and pasted into the path of %FR_HOME%/webapps/webroot/WEB-INF/lib. Restart the designer afterward.
4. Build an Axis Server
This article takes axis1.4 as an example. First, download axis-bin-1_4.zip and extract the axis directory into %TOMCAT_HOME%/webapps/. Second, start Tomcat and go to https://localhost:8443/axis/(Here we use HTTPS), where you should see information as follows saying the deployment of axis has succeeded.
II. Example
1. Deploy WebService
Publish a WebService application named TestWS2TDClient.jws under axis project using the JWS method, and return array data.
Create the TestWS2TDClient.java file with the following contents:
public class TestWS2TDClient {
public String[][] getTD() {
String[][] a = { { "City", "Salesperson", "Sales Volume" }, { "Los Angeles", "Anna", "230" }, { "Los Angeles", "Alex", "190" },
{ "Los Angeles", "Jack", "320" }, { "Los Angeles", "Apple", "210" }, { "San Fransisco", "Faye", "150" }, { "San Fransisco", "Sammy", "280" } };
return a;
}
}
Rename the TestWS2TDClient.java file to TestWS2TDClient.jws and put it into %Tomcat_HOME%\webapps\axis\
Go to https://localhost:8443/axis/TestWS2TDClient.jws in the browser as shown below:
Click on "Click to see the WSDL". You'll see the following page with the correct configuration.
Note: if an error message indicates that tools.jar is required, please copy and paste the tool.jar in JDK into folder "lib" under axis.
2. Access WebService Data Source with Java
Send out a SOAP request from Java to access the TestWS2TDClient.jws WebService and get the returned data.
try {
// ignore ssl verification
AxisProperties.setProperty("axis.socketSecureFactory", "org.apache.axis.components.net.SunFakeTrustSocketFactory");
String endpoint = "https://localhost:8443/axis/TestWS2TDClient.jws";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName(new QName("https://localhost:8443/axis/TestWS2TDClient.jws",
"getTD"));
String[][] ret = (String[][])call.invoke(new Object[] {});
return ret;
} catch (Exception e) {
e.printStackTrace();
}
Note: SOAP (abbreviation for Simple Object Access Protocol) can be applied to send out a request calling for objects, and the server will return results afterward correspondingly. Its messages are in XML format and encapsulated into HTTP protocol-compliant messages.
3. Define Class Dataset
When accessed, WebService will return data to the client. In this case, a string array is returned. Define a class WebServiceTableData.java extending from AbstractTableData to convert the received array into a class dataset. Please go to the following URL for more information: https://github.com/finereport-overseas/example/blob/release/10.0/src/main/java/com/fr/data/WebServiceTableData.java
4. Compile Class Dataset
Copy and paste the complied WebServiceTableData.class file into %FR_HOME%/webapps/webroot/WEB-INF/classes/com/fr/data.
5. Use Class Dataset
Create a new report and select the pre-defined class dataset (WebServiceTableData.class) in dataset configuration. Click on Preview and you'll see the following window if the Tomcat server is up and running.