[Download] | [Documentation Home] | [Release Note]

Eclipse WTP Integration

WSO2 Application Server (AppServer) now supplies pluggable components in the form of Eclipse WTP plugins which enable it to be integrated with the popular IDE Eclipse. This guide is meant to demonstrate the use of the newly introduced AppServer Web Services tools in tandem with the Eclipse Web Tools Platform Project using WTP 2.0 drivers. The guide shows how to create a simple Web service and client based Web service operations using the linked Dynamic Web Projects of WTP.

Set up

Note : This feature is a new addition to AppServer v2.0. Also, since Eclipse WTP requires Java 2 SDK 5.0 or higher, AppServer Eclipse WTP Plugins will require Java 2 SDK 5.0 or higher.

  1. Download Eclipse WTP 2.0 and extract it to a desired location.

    JDK 1.5 Eclipse WTP 2.0 requires j2sdk 5.0 or higher

  2. Close any running instances of Eclipse WTP before starting the installation.
  3. Go to CARBON_HOME/bin and run install.bat script if in the Windows environment, or install.sh in a Unix based environment.

    You will be asked for the installation mode.

    Please select your installation mode : [1/2]

    1) WSO2 AppServer Servlet Container Installation

    2) WSO2 AppServer Eclipse WTP Plugins Installation

  4. Select option 2 to Install the AppServer Eclipse WTP Plugins

    : 2

    Selection: WSO2 AppServer Eclipse WTP Plugins Installation

    Starting AppServer Eclipse WTP Plugin installation...

    Please enter Eclipse WTP Home :

  5. Provide the correct Eclipse WTP Home Location :
  6. If you did not close the running instance of Eclipse WTP, you will be shown this message.

    Please shutdown the Eclipse instance [c:\eclipse] , If Already Running ...

    Copying AppServer Eclipse WTP Plugins C:\eclipse\plugins

    OK

    WSO2 AppServer Eclipse WTP Plugin installation was successful.

    Please restart Eclipse WTP Instance..

  7. Setting AppServer Preferences in Eclipse WTP

    Now we point Eclipse WTP to the downloaded AppServer Runtime. Open Window -> Preferences -> Web Services -> AppServer Preferences



    AppServer Home Preferences

    Set the AppServer HOME variable to point to the local AppServer location.

    Also on the AppServer Preferences page, we can set the default setting for the Web services creation codegen options, Web services client codegen options and service archive options



    AppServer Preferences

    Starting AppServer Through Eclipse WTP

    After setting the preferences, we can start the AppServer from the AppServer Main menu or from the AppServer Tool bar.



    AppServer Menu Start



    AppServer Button Start

    After starting AppServer, it will automatically display the console and the WTP internal browser with the AppServer HOME Page.



    AppServer Starting



    AppServer Sign-In



    AppServer Home

    You can shutdown the eclipse instance either from the menu or the toolbar.



    AppServer Menu Stop



    AppServer Button Stop

    Creating a Web Services Enabled Dynamic Web Project with AppServer Runtime Support

    Now we create a project with the support of AppServer features. Open File -> New -> Other... -> Web -> Dynamic Web Project



    Select Wizard

    Select the name of the Project as the Dynamic Web project name (you can specify any name you prefer).



    Dynamic Web Project

    Click on the New Target Runtime button and select the WSO2 AppServer 2.0 target runtime.



    New Server Runtime

    Then click Finish. This will add the target runtime and the configurations of the default AppServer settings.



    Dynamic Web Project Updated

    Click Next.

    Then on the facet creation page, select the AppServer Web Services Facets , Core and Extentions.



    Project facets

    Click Next. Then accept the default configuration settings on the Configure Web Modules Page.



    Web Module

    Click Finish and it will create the Dynamic Web Project with the support of AppServer Web Services functionalities.



    Management Console

    Creating a Bottom Up JAVA bean Web Service Using AppServer WTP Tools

  8. Create the JAVA Bean that has to be exposed as the Web service. For example, we will write a LocalTimeBot, which will bring the local time from the system.
  9. package test;
    
    import java.util.Calendar;
    import java.util.GregorianCalendar;
    
    public class LocalTimeBot {
        public String getLocalTime() {
            Calendar cal = new GregorianCalendar();
            return cal.getTime().toString();
        }
    }

    Create a LocalTimeBot class inside the src under the given package test. Then compile and build the project.



    Project wizards

  10. Select LocalTimeBot.java, open File -> New -> Other... -> Web Services -> Web Service


  11. Project wizards

  12. Click on the Web Service runtime link to select the WSO2 AppServer runtime.


  13. Project wizards



    Project wizards

  14. This page is the service.xml selection page. If you have a custom services.xml, you can include that by clicking the Browse button. For the moment, just leave it as the default.


  15. Project wizards



    Project wizards

  16. This page is the Web services publication page, accept the default values.


  17. Project wizards

    Click Finish.

  18. By now the service will be available on AppServer and you will be able to carry out the AppServer provided functionalities, the "Try It" functionality, for example .


  19. Project wizards



    Project wizards

    Creating a Top Down Web Service Using AppServer WTP Tools

  20. If we have a Web service definition in the form of WSDL, we can create a service from that WSDL
  21. Import the getTripple.wsdl to the created TestWSProject


  22. Project wizards

  23. We will now invoke the Web service creation wizard with respect to the newly imported WSDL. Select the getTripple.wsdl source, then select File -> New -> Other... -> Web Services -> Web Service


  24. Project wizards

  25. Because the wizard was invoked related to a correct WSDL, the correct Web services scenario will be picked automatically with the correct service definition. Make sure that you have moved the scale to Start service. Select the Web service runtime hyperlink and then select the AppServer Web service runtime. Click OK.



    Project wizards

  26. This page is the skeleton configuration page. You can customize the skeleton generation using the controls on this page. For this example, just leave the default values. Click Finsh to generate the service.


  27. Project wizards

  28. After clicking Finish, the generated skeletons will be available on the src directory of the project. The skeleton service will be deployed on AppServer as well.


  29. Project wizards

  30. We can generate the client and invoke the Web service features that AppServer provides, like 'Try It' etc.
  31. Generating the Client and Invoking the Service

  32. Go to the LocalTimeBot service you created first ,through the AppServer console and select the endpoints. AppServer supports ?wsdl of the services. So for the client creation of the service we will use the http://127.0.0.1:9762/services/LocalTimeBot?wsdl as the service definition.


  33. Project wizards

  34. Now we'll generate the client for the newly created service by referring to the ?wsdl generated by the AppServer Server. Open File -> New -> Other... -> Web Services -> Web ServiceClient


  35. Project wizards

  36. Paste the URL that was copied earlier into the service definition field.


  37. Project wizards

  38. The next page is the Client Configuration Page. Accept the default values and click Finish.


  39. Project facets

  40. This will create the client stubs for our TestWSProject.


  41. Project wizards

  42. Using the stub we will write the simple client program to invoke the service.
  43. package test;
    
    import java.rmi.RemoteException;
    
    import org.apache.axis2.AxisFault;
    
    public class LocalTimeBotClient {
    
        public static void main(String[] args) {
            LocalTimeBotStub stub;
            try {
                stub = new LocalTimeBotStub();
                LocalTimeBotStub.GetLocalTimeResponse res = stub.getLocalTime();
                System.out.println("Local Time :" + res.get_return());
            } catch (AxisFault e) {
                e.printStackTrace();
            } catch (RemoteException e) {
                e.printStackTrace();
            }
    
        }
    
    }
      
  44. We can import the LocalTimeBotClient to TestWSProject


  45. Project wizards

  46. Compile and run the project.


  47. Project wizards

    Testing the Web Service with Web Services Explorer (WSE)

  48. Web Service Explorer (WSE) is a WTP built in application that can be used as a dynamic client to invoke the Web services hosted in the Internet. You can select the tab on the first service creation page upto test, and then after the service creation the WSE will be opened automatically with the service endpoint. With that open WSE, the correct endpoint to the service can be invoked with the dynamic client feature in it. For more information about testing with dynamic client in WSE please refer here
  49. == If the configuration does not work out of the box for you ==

    * Increase the default memory usage in eclipse.ini file. Normally Eclipse WTP comes with -Xms40m -Xms256m Normally with the servers inside WTP would require -Xms256m -Xms512m to work efficiently.

    * In some Linux distros the Eclipse Internal Browser will not function correctly. If that becomes an issue the users need to Enable SSL on Mozilla browser.

    Steps Enable SSL on mozilla

    export MOZILLA_FIVE_HOME=/usr/lib/mozilla-firefox

    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MOZILLA_FIVE_HOME

    The open mozilla firefox and type about:config on the address bar and set the below settings

    1. enable security.enable_ssl2 to true

    2. enable security.enable_ssl3 to true

    3. enable security.ssl3.rsa_rc4_40_md5 to true

    Restart firefox and restart eclipse, the internal browser will work properly.


Tools on AppServer Eclipse WTP Integration

Since AppServer version 2.1 release, AppServer Eclipse WTP Inegration comes with set of tools that will enable the will enhance the web service users productivity. These tools are built using the eclipse wizard framework with all the support of the wizard navigation with back and forh persistance of data. The tools include,

AppServer Tools Menu
Figure 1

1) AppServer JAVA2WSDL
2) Dump AppServer Archive
3) Module Archive Validation
4) Service Archive Validation
5) WSDL Converter

AppServer Toolbar
Figure 2

In the AppServer Eclipse WTP Inegration we have added a seperate Menu item with these tools added, [Figure 1] and toolbar also [Figure 2].

  • AppServer JAVA2WSDL
This is the newly added tool that enables the feature of java2wsdl. This is the AppServer feature that comes with axis2 that enables generation of the WSDL by taking input a Java class, which describes a Web service for invoking the classes methods. This will happen according to the Axis2 constrains.
  • Dump AppServer Archive
This is the tool that dump a AppServer deployable service arvhice and a offline script that enables the rebuilding of the arvhive with the resources. Currently this tool support to output and Apache Ant build script per IDE generated web service. With the help of this web service user can update the service offline and build it again with out the help od the IDE. All the dump services will be available on the [Eclipse_Workspave]/dumpaar and the script will be available inside each service and when it was invoked through Ant the the new service archive will be created inside the target directory in each service using the current offline resources.

  • Module Archive Validation
This tool will validate the given module.xml and output the results of the validation. Currently any module archive or a module.xml it self can be point to the tool and when the input is correctly given the tool will talk to AppServer and get the validation results in the next page of the wizard from the AppServer Application server. The valid input files are .mar and .xml and when ever the user requires now he can get the module archive validation productively with this too.
  • Service Archive Validation
This tool will validate the given services.xml and output the results of the validation. Currently any service archive or a service.xml it self can be point to the tool and when the input is correctly given the tool will talk to AppServer and get the validation results in the next page of the wizard from the AppServer Application server. The valid input files are .aar .zip and .xml and when ever the user requires now he can get the service archive validation productively with this too.
  • WSDL Converter
This tool will convert a given WSDL 1.1 version document to WSDL 2.0 document. The user can input any URL of the WSDL 1.1 document and get the WSDL 2.0 verison of the same web service as the result occording to the Axis2 constrains.