Documentation

##### WSO2 WSAS 2.2-RC1

- Release Notes
- Contents
- Home

##### Downloads

- Releases

##### Documentation

- User Guide
- FAQs
- Installation Guide
- Source
- Running Behind a Proxy
- Data Services Guide
  - RDBMS Data Source
  - CSV Data Source
  - Excel Data Source
  - JNDI Data Source
- EJB Guide
- Clustering Guide
- JMX Guide
- XKMS Guide
- Changing Keys

##### Samples

- Chad
- Commodity Quote
- Data Services
- Flickr
- Javascript
- Jaxws
- JiBX
- Mtom
- STS
- Trader
- Tiny URL
- Metadata Exchange
- WS-Transfer
- XML Key Managment Specification
- Cluster Management

##### API Documentation

- Java Docs

##### Tools

- Code Generation
- Change Password
- Eclipse IDE Integration
- TCP Monitor
- WSDL2Code
- WSDL View
- Try It
- AAR Validation
- MAR Validation

##### Resources

- News

##### Get Involved

- Mailing Lists
- Integration

##### Project Information

- Project Team
- Issue Tracking
- License

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

# Eclipse WTP Integration

WSO2 Web Services Application Server (WSAS) 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 WSAS 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 WSAS v2.0. Also, since Eclipse WTP requires Java 2 SDK 5.0 or higher, WSAS 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 WSAS_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 WSAS Servlet Container Installation

   2) WSO2 WSAS Eclipse WTP Plugins Installation

4. Select option 2 to Install the WSAS Eclipse WTP Plugins : 2

   Selection: WSO2 WSAS Eclipse WTP Plugins Installation

   Starting WSAS 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 WSAS Eclipse WTP Plugins C:\eclipse\plugins

   OK

   WSO2 WSAS Eclipse WTP Plugin installation was successful.

   Please restart Eclipse WTP Instance..

# Setting WSAS Preferences in Eclipse WTP

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

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

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

# Starting WSAS Through Eclipse WTP

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

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

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

# Creating a Web Services Enabled Dynamic Web Project with WSAS Runtime Support

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

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

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

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

Click Next.

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

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

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

# Creating a Bottom Up JAVA bean Web Service Using WSAS WTP Tools

7. 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.

    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.

8. Select LocalTimeBot.java, open File -> New -> Other... -> Web Services -> Web Service
9. Click on the Web Service runtime link to select the WSO2 WSAS runtime.

10. 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.

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

Click Finish.

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

# Creating a Top Down Web Service Using WSAS WTP Tools

13. If we have a Web service definition in the form of WSDL, we can create a service from that WSDL
14. Import the getTripple.wsdl to the created TestWSProject
15. 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
16. 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 WSAS Web service runtime. Click OK.
17. 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.
18. After clicking Finish, the generated skeletons will be available on the src directory of the project. The skeleton service will be deployed on WSAS as well.
19. We can generate the client and invoke the Web service features that WSAS provides, like 'Try It' etc.

# Generating the Client and Invoking the Service

20. Go to the LocalTimeBot service you created first ,through the WSAS console and select the endpoints. WSAS 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.
21. Now we'll generate the client for the newly created service by referring to the ?wsdl generated by the WSAS Server. Open File -> New -> Other... -> Web Services -> Web ServiceClient
22. Paste the URL that was copied earlier into the service definition field.
23. The next page is the Client Configuration Page. Accept the default values and click Finish.
24. This will create the client stubs for our TestWSProject.
25. Using the stub we will write the simple client program to invoke the service.

    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();
            }

        }

    }

26. We can import the LocalTimeBotClient to TestWSProject
27. Compile and run the project.

# Testing the Web Service with Web Services Explorer (WSE)

28. 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

# == 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 WSAS Eclipse WTP Integration

Since WSAS version 2.1 release, WSAS 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,
Figure 1
1) WSAS JAVA2WSDL
2) Dump WSAS Archive
3) Module Archive Validation
4) Service Archive Validation
5) WSDL Converter
Figure 2
In the WSAS Eclipse WTP Inegration we have added a seperate Menu item with these tools added, [Figure 1] and toolbar also [Figure 2].

- WSAS JAVA2WSDL

This is the newly added tool that enables the feature of java2wsdl. This is the WSAS 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 WSAS Archive

This is the tool that dump a WSAS 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 WSAS and get the validation results in the next page of the wizard from the WSAS 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 WSAS and get the validation results in the next page of the wizard from the WSAS 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.

###