The jws Method of WebService Program Dataset

  • Last update:February 03, 2021
  • 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.

    1.png

    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.

    Attachment List


    Theme: Secondary Development
    Already the First
    Already the Last
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy