WebService Dataset Accessed through JDBC

  • Last update:  2020-12-17
  • 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.

    1583829078420513.png


    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.

    1576142430882991.png

    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.


    111.png


    2) Place the services.xml file into META-INF.


    112.png


    3) Put in the created JDBC data extraction class MyService.class into service.


    123.png


    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.

    1576216646887703.png

    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.

    image.png

    Attachment List


    Theme: Secondary Development
    • 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