[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.
- 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
- Close any running instances of Eclipse WTP before starting the
installation.
- 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
- 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 :
- Provide the correct Eclipse WTP Home Location :
- 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
- 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.

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

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

- This page is the Web services publication page, accept the default
values.
Click Finish.
- 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
- If we have a Web service definition in the form of WSDL, we can create
a service from that WSDL
- Import the getTripple.wsdl to the created TestWSProject
- 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
- 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.
- 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.
- 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.
- 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
- 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.
- 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
- Paste the URL that was copied earlier into the service definition
field.
- The next page is the Client Configuration Page. Accept the default
values and click Finish.
- This will create the client stubs for our TestWSProject.
- 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();
}
}
}
- We can import the LocalTimeBotClient to TestWSProject
- Compile and run the project.
Testing the Web Service with Web Services Explorer (WSE)
- 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].
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.
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.
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.