Popular Posts

Tuesday, December 30, 2008

How to plug service hosting components in to WSO2 ESB

With the revolutionary WSO2 carbon framework, plugging in service hosting components in to WSO2 Enterprise Service Bus (ESB) is just a matter of seconds! It is extremely simple.

WSO2 ESB is an message mediation framework and the service endpoints usually hosted in a separate JVM. However there may be requirements to host the services inside ESB. There are different types of services you can deploy in a service container.

Axis2 web services
Pojo services

EJB services

Data services

Spring web services

Axis1 services
JaxWS services

Now, you can add any of these service hosting components in to your ESB. Lets see how it can be done.

1. Download WSO2 Enterprise Service Bus (ESB) -2.0 beta2
2. Extract the downloaded zip
3. Go to the bin directory in the extracted folder (ESB_HOME/bin) and run wso2server.sh or wso2server.bat
4. Point you browser to the URL https://localhost:9443/carbon and login as an admin (Use "admin", "admin" as the username and password)



5. Suppose you want JAXWS services are hosted in ESB. Then you need to have the jaxws service hosting components. You will be able to download the individual components from WSO2 Oxygen Tank soon. However, we will downlaod WSO2 WSAS-3.0-beta2 and get the components from it. Therefore, please download WSO2 WSAS 3.0-beta2 and extract the downloaded zip file in to local file system. (Lets name the extracted directory as WSAS_HOME)

6. Go to WSAS_HOME/webapps/ROOT/WEB-INF/plugins. You will find a lot of libraries inside that directory.
Copy org.wso2.carbon.jaxwsservices.ui_SNAPSHOT.jar, org.wso2.carbon.jaxwsservices_SNAPSHOT.jar and org.wso2.carbon.jaxws-2.1.jar files and paste them into ESB_HOME/webapps/ROOT/WEB-INF/plugins
7. Restart WSO2 ESB server
8. Log in to ESB management console again. You will find the JAXWS service component is listed in the left menu.



In this way, you can add any of the above service components into ESB. For example, if you want Axis2 service component inside ESB, you just need to copy org.wso2.carbon.aarservices-SNAPSHOT.jar and org.wso2.carbon.aarservices.ui-SNAPSHOT.jar as explained above.

Friday, December 19, 2008

A software architect's view on WSO2 QA methodology

Afkham Azeez, a software architect at WSO2 nicely puts together his observations of Quality Assurance practices by comparing them with the traditional QA processes.
As I always believe, the feedback of QA tasks must be come from the development team first. In an agile software process, it is really important to have feedback from the collegues of your team. You work with them. They know your approach and how you carry out your duties than the other hidden managers. Therefore, a good feedback from development team is definitely help a QA team to move forward.
I totally agree with Azeez on his idea on traditional vs agile/collaborative QA. We don't want our QA engineers to spend their valuable time filling huge excel sheets and writing comprehensive plans which are not even looked at during the test execution phases. Instead, our QA engineers learn SOA technologies, involve in community discussions, maintain technical blogs, researching on testability of features etc.. They are in a position to take over the QA testing of any SOA middleware with minimum ramp-up time. Since traditional QA people don't even look at the source code, our team write clients to invoke web services in reliable/secure manner, write DB scripts to port our products to run on different DBMSs and help developers in minor bug fixes during rush release cycles.
I must appreciate Azeez for sharing his view on QA which will help us to do a better job.

Saturday, December 13, 2008

New look of WSO2 WSAS SOAP Message Tracer

Soap Tracer may not be a strange tool if you are familiar with WSO2 Web Services application server (WSAS). However, you will notice a new look and improved graphical representation of SOAP messages in Soap Tracer shipped with WSAS 3.0.
You will experience the difference with the newly released WSAS-3.0-beta1

- Download and unzip the binary distribution
- Log in to management console with user name and password, admin/admin
- Select Soap Message Tracer in the left menu
- Change the status to ON
- Invoke a service (Simply run tryit with the default HelloService)
- Go back to Soap Message Tracer and see the request and soap messages

Sunday, December 7, 2008

Fast Reliable Integration with WSO2 Carbon

I was out of blogging for few weeks due to the extremely busy schedule of WSO2's next revolutionary product suite, Carbon.
Samisa has explained the summarized view of Carbon in his post, Carbon in Pictures.
With Carbon, you will get the features of fully fledged SOA platform. You will plug in Service hosting components in to ESB with minimum effort. There are much more..
Stay tuned.. This blog will be updated with a lot of helpful materials once Carbon is out.

Sunday, November 2, 2008

Axis2 java2wsdl maven plugin

I demonstrated the usage of Maven2 WSDL2Code plugin in a previous post. Apache Axis2 provides with a Java2WSDL maven2 plugin as well. Maven2 Java2Wsdl plugin can be used to generate WSDL from a java class. The following steps will help you to create a wsdl from a java class using Axis2 java2wsdl maven plugin.

Step 1
Create a mavan project (See step 1 of ).
Create a java class in the source directory of your maven project. (i.e:- Create Calculator.java class at \src\main\java\com\test directory)


Step 2

Update the pom.xml of your maven project as follows.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>calculator</artifactId>
<version>1.0-SNAPSHOT</version>
<name>calculator</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-java2wsdl-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>java2wsdl</goal>
</goals>
</execution>
</executions>
<configuration>
<className>com.test.Calculator</className>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
</project>

Note the highlighted elements in the above pom. First we added a new <plugin> to use java2wsdl goal. This goal accepts a set of parameters as explained in Axis2 online documentation.
In this example we used the simplest configuration parameter, <className>, which defines the fully qualified name of class from which the WSDL is generated.

Also, make sure to add a dependency to Axis2 jars in your pom.xml.

Step 3

Go to the root directory of your project structure and run the following command.

mvn clean axis2-java2wsdl:java2wsdl

You could find the generated wsdl at target\generated-resources\java2wsdl\ directory.

Saturday, October 25, 2008

Changing the default class loading mechanism of JBoss 4.2.* and WebLogic

Application servers use different class loading/delegation mechanisms. Therefore, we should understand them when deploying enterprise applications. In most cases, we need to override the default class loading behavior of application servers.
Suppose your web application wants to load classes from its own class loader first without delegating to parent. Then the following simple configurations will help you to override default delegation pattern in BEA WebLogic (version 8.* or 10) and JBOSS 4.2.*.

In WebLogic:

Set <prefer-web-inf-classes> to true in WEB-INF/weblogic.xml of your war.

Read WebLogic Server application classloading for more information.

In JBoss:

Set java2ParentDelegation to false in WEB-INF/jboss-web.xml as follows.

<loader-repository>
org.test:loader=archive-name
<loader-repository-config>
java2ParentDelegation=false
</loader-repository-config>
</loader-repository>

For more information about JBoss class loading, have a look at JBoss classloading configuration guide

Tuesday, October 21, 2008

How to use Maven2 WSDL2Code plugin in Axis2

Apache Axis2 ships with a lot of useful tools to make web service developer's life easier. Maven2 WSDL2Code plugin is one of them which can be used to generate server side skeletons or client stubs from a given WSDL using a maven pom.xml.
Lets see how this plugin can be used.

Pre-requistes:
Apache Maven2

Step1

Create a maven project using maven archetype template (You may ignore this step and use an existing project if you are familiar with maven)

mvn archetype:create -DgroupId=com.test -DartifactId=calculator

This will create a maven project structure as follows.



Step 2

Create a directory (i.e:- resources) at src\main and copy your WSDL file there.
Now, remove the existing contents of the auto-generated pom.xml (calculator\pom.xml) and add the following configuration.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>calculator</artifactId>
<version>1.0-SNAPSHOT</version>
<name>calculator</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-wsdl2code-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<goals>
<goal>wsdl2code</goal>
</goals>
</execution>
</executions>
<configuration>
<packageName>org.charitha</packageName>
<wsdlFile>src/main/resources/calculator.wsdl</wsdlFile>
<databindingName>adb</databindingName>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
</project>

Note the highlighted elements in the above pom. First we added a new <plugin> to use wsdl2code goal. The WSDL2Code goal takes a set of input parameters as explained here.
In this example, we use 3 configuration parameters.
<packageName> - The generated source will be added to this package
<wsdlFile> - The location of the input wsdl file
<databindingName> - Databinding mechanism used for code generation

Also, we need to add a dependency to Axis2 jars.

Step 3

Go to the root directory of your project structure (i.e:- calculator directory where pom.xml exists) and run the following command.

mvn clean axis2-wsdl2code:wsdl2code

You could find the generated classes at target\generated-sources\axis2\wsdl2code directory.

Note: The sample wsdl used for the above example can be found at http://ww2.wso2.org/~charitha/calculator.wsdl

RESTful PHP Web Services by Samisa Abeysinghe



Samisa Abeysinghe
, the director of engineering at WSO2, attempts to explain the basic architectural concepts and step through examples of consuming and creating RESTful web services in PHP through his new book. This should be a vital reference for anyone interested in SOA.
You could find more details of this book from PACKT web.

Monday, October 13, 2008

Reading a property of Axis2 services.xml from service Implementation class

There have been questions raised in Axis2 user list about reading some properties defined in services.xml from service implementation class.
An easy way of doing that is as follows.

1. Suppose your services.xml is as follows and it has a parameter named, TestProperty.

<service name="ParameterService">
<messageReceivers>
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
</messageReceivers>
<parameter name="ServiceClass">org.test.MyParameterService</parameter>
<parameter name="TestProperty">This is a test property</parameter>

</service>

2. We need to read the value of "TestProperty" parameter from service implementation class.
It can be done using MessageContext as follows.

import org.apache.axis2.context.MessageContext;

public class MyParameterService {
public void readProperty(){
MessageContext mc = MessageContext.getCurrentMessageContext();
String prop = mc.getCurrentMessageContext().getAxisService().getParameter("TestProperty").getParameterElement().getText();
System.out.println(prop);
}

}

Now you can create a service archive with this class and copy it to AXIS2_HOME/repository/services directory. Then start axis2server.bat and go to http://localhost:8080
You will notice that the service will be deployed there. Then invoke the service by sending HTTP GET request as follows
http://localhost:8070/axis2/services/ParameterService/readProperty

Look at the Axis2server console. You will see "This is a test property" message is printed there.

Sunday, October 12, 2008

How to make an OSGI bundle using maven bundle plugin

OSGI (Open systems Gateway Initiative) specification defines a complete and dynamic component model which can be remotely installed, started, updated, stopped and uninstalled without restarting JVM. I'm not going to discuss the specification details of OSGI. You can find a lot of information from www.osgi.org
The objective of this post is to create a simple OSGI bundle using Apache Felix maven bundle plugin.

Pre-requisites:
Apache Maven2

Step 1
First we need to create a simple java class and which must be included in a proper directory structure therefore we can use Maven2 to build the source.

Create the following directory structure in your file system.

Create the following interface.

package org.wso2;

public interface GreetingService {
public void sayGreeting(String s);
}

Create an Impl directory under wso2 and add the following class in there.

package org.wso2.Impl;

import org.wso2.GreetingService;

public class GreetingServiceImpl implements GreetingService {

public void sayGreeting(String s){
System.out.println("Welcome " +s);

}
}

Step 2

We have created an interface and its implementation. We have not done anything new for you so far.
Since we are going to create an OSGI bundle, we need to add a BundleActivator though it is not mandatory to have. Bundle Activator class is used to start and stop the bundle when it is installed on an OSGI framework such as Knopflerfish.
Lets create an implementation of BundleActivator at the same package where GreetingServiceImpl is placed.

package org.wso2.Impl;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.wso2.Impl.GreetingServiceImpl;

public class Activator implements BundleActivator {
public void start(BundleContext bundleContext) throws Exception {
GreetingServiceImpl greetingServiceImpl = new GreetingServiceImpl();
greetingServiceImpl.sayGreeting("Charitha");

}

public void stop(BundleContext bundleContext) throws Exception {

}
}

Step3
Now we can create the pom.xml to compile above classes and make an OSGI bundle (Basically we need to generate manifest headers in MANIFEST.MF of the generated bundle jar)
Here is the complete pom.xml. Note the highlighted section.

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>


<groupId>org</groupId>
<artifactId>wso2</artifactId>
<packaging>bundle</packaging>
<version>1.0</version>

<dependencies>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.osgi.core</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>

<name>Simple OSGI example</name>
<description>A bundle to demonstrate maven bundle plugin.</description>


<properties>
<bundle.namespace>${pom.groupId}.${pom.artifactId}</bundle.namespace>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>1.4.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Private-Package>${bundle.namespace},${bundle.namespace}.Impl</Private-Package>
<Export-Package>${bundle.namespace}</Export-Package>
<Bundle-Activator>${bundle.namespace}.Impl.Activator</Bundle-Activator>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>

The <Export-Package> element tells the plugin which of the available packages to copy into the bundle and export. The <Private-Package> instruction indicates which of the available packages to copy into the bundle but not export. In other words, private packages are not exported by the bundle.
Here, we define our impl package, org.wso2.Impl as a private package.
These elements will be added as manifest headers in resulting bundle jar as we will see shortly.

Step 4
Save pom.xml at the root directory of the above folder tree. (e.g:- example directory) and run it with mvn clean install

Bundle will be created at the target directory. Open it and look at META-INF/MANIFEST.MF

Manifest-Version: 1.0

Built-By: Charitha

Created-By: Apache Maven Bundle Plugin

Bundle-Activator: org.wso2.Impl.Activator

Import-Package: org.osgi.framework;version="1.3",org.wso2

Bnd-LastModified: 1223869521406

Export-Package: org.wso2

Bundle-Version: 1.0

Bundle-Name: Simple OSGI example

Bundle-Description: A bundle to demonstrate maven bundle plugin.

Build-Jdk: 1.5.0_14

Private-Package: org.wso2.Impl

Bundle-ManifestVersion: 2

Bundle-SymbolicName: org.wso2

Tool: Bnd-0.0.238


Have a look at the Export-Package and Private-Package headers which were added to the manifest as we defined them in pom.xml.
Now our bundle is ready to deploy in an OSGI framework. We will see how this bundle can be deployed on Knopflerfish in a future blog post.

How to add a custom SOAP header to the request using AXIOM

Suppose you want to add the following SOAP header block to your web service request message.
<myNS:header xmlns:myNS="http://ws.org">
This is a custom soap header
</myNS:header >

There are different approaches to add user defined headers to the request soap messages. Lets see how it could be done using AXIOM in simpler way.
In this example we are going to invoke Axi2 default version service with adding a custom soap header in to the request.

Pre-requisites
Download and install Apache Axis2
Install Apache Tcpmon

Step 1

Start Axis2 server by running AXIS2_HOME/bin/axis2server.bat{sh}
Go to http://localhost:8080. You will see that the default version service is deployed there.

Step 2

Now, we need to generate client stubs. Go to AXIS2_HOME/bin and run wsdl2java.bat{sh} with the following parameters.
WSDL2Java -uri http://localhost:8080/axis2/services/Version?wsdl -o out -uw

The client stubs will be generated in a directory called "out".

Now, write a client importing the generated stub classes as follows(You can easily create a project in Eclipse using the generated Build.xml)

import java.rmi.RemoteException;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axis2.AxisFault;
import sample.axisversion.ExceptionException0;
import sample.axisversion.VersionStub;


public class CustomSoapHeaderClient {

public static void main(String[] args) throws AxisFault{

String url = "http://localhost:8090/axis2/services/Version";
VersionStub stub = new VersionStub(url);

OMFactory omFactory =OMAbstractFactory.getOMFactory();
OMNamespace omNamespace = omFactory.createOMNamespace("http://ws.org", "myNS");
OMElement header = omFactory.createOMElement("header", omNamespace);
header.setText("This is a custom soap header");
stub._getServiceClient().addHeader(header);

try {
System.out.println(stub.getVersion());
} catch (RemoteException e) {
e.printStackTrace();
} catch (ExceptionException0 e) {
e.printStackTrace();
}
}


}

Note the highlighted code which creates the custom soap header.

Step 3

We can visualize the soap request using Tcpmon. Therefore open tcpmon and configure listen port in 8090 and target port 8080.
Compile and run the above client. You will see the following message in request pane of Tcpmon.

<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Header>
<myNS:header xmlns:myNS="http://ws.org">This is a custom soap header</myNS:header>


Monday, October 6, 2008

SOAP over JMS with Axis2

Axis2 provides a JMS transport implementation which can be used to send SOAP messages over JMS. This post will help you to -
  • Configure JMS transport in Axis2
  • Generate Axis2 client
  • Invoke default version service by sending request SOAP message over JMS
  • Monitoring messages via JConsole
I assume Apache ActiveMQ is used as our JMS implementation. However, you are free to use any other stack.

Pre-requisites
1. Install the latest version of Apache Axis2 binary distribution
2. Install Apache ActiveMQ 5.0.0

Step 1
First, we need to start ActiveMQ message broker. Go to ActiveMQ_Install_dir/bin and run activemq.bat



Step 2
In order to configure the JMSListener in axis2.xml, uncomment the following section.
<transportReceiver name="jms" class="org.apache.axis2.transport.jms.JMSListener">
<parameter name="myTopicConnectionFactory">
<parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
<parameter name="java.naming.provider.url">tcp://localhost:61616 </parameter>
<parameter name="transport.jms.ConnectionFactoryJNDIName">TopicConnectionFactory </parameter>
</parameter>

<parameter name="myQueueConnectionFactory">
<parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory </parameter>
<parameter name="java.naming.provider.url">tcp://localhost:61616 </parameter>
<parameter name="transport.jms.ConnectionFactoryJNDIName">QueueConnectionFactory </parameter>
</parameter>

<parameter name="default">
<parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory </parameter>
<parameter name="java.naming.provider.url">tcp://localhost:61616 </parameter>
<parameter name="transport.jms.ConnectionFactoryJNDIName">QueueConnectionFactory </parameter>
</parameter>
</transportReceiver>

Also, uncomment the transport Sender which is in the Transport-outs section of axis2.xml.

<transportSender name="jms" class="org.apache.axis2.transport.jms.JMSSender"/>

Step3
The following ActiveMQ libraries must be copied to the Axis2 lib directory (AXIS2_HOME/lib).
  • activeio-core-3.1-SNAPSHOT.jar (ActiveMQ_Install_dir\lib\optional)
  • activemq-core-5.0.0.jar (ActiveMQ_Install_dir\lib\)
  • geronimo-j2ee-management_1.0_spec-1.0.jar (ActiveMQ_Install_dir\lib\)
  • geronimo-jms_1.1_spec-1.0.jar (ActiveMQ_Install_dir\lib\)
Step 4
Start Axis2server and go to http://localhost:8080
Then select the default version service.
The WSDL of the Version service will be displayed. You will notice the following port.

<wsdl:port name="VersionJmsSoap11Endpoint" binding="ns:VersionSoap11Binding">
<soap:address location="jms:/Version?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://localhost:61616"/>
</wsdl:port>

This implies that the Version service is now exposed over JMS transport as well. Lets write a client and send SOAP requests through JMS.

Step 5

Generate Client stubs with the following command.
AXIS2_HOME/bin/WSDL2Java -uri http://localhost:8070/axis2/services/Version?wsdl -o out -uw

The client stubs will be generated in a directory called "out".

Now, write a client importing the generated stub classes as follows(You can easily create a project in Eclipse using the generated Build.xml)

import java.rmi.RemoteException;
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
import sample.axisversion.ExceptionException0;
import sample.axisversion.VersionStub;


public class JMSClient {

public static void main(String[] args) throws AxisFault{
ConfigurationContext cc = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null,"D:\\axis2\\axis2-client\\conf\\axis2.xml");
String url = "jms:/Version?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://localhost:61616";
VersionStub stub = new VersionStub(cc,url);

try {
System.out.println(stub.getVersion());
} catch (RemoteException e) {
e.printStackTrace();
} catch (ExceptionException0 e) {
e.printStackTrace();
}
}

}

We need to enable JMS in client side too. Therefore, create a client repository (Just create a directory and copy the axis2.xml in there). Make sure to enable JMS transportReceiver and TransportSender in client's axis2.xml.

Step 6

Run the client. You will get the response back with axis2 version.
Now we need to look at the messages transmitted through JMS channel. Open a command prompt and type 'jconsole' and hit enter.
Connect to ActiveMQ agent.
Click on MBeans and select org.apache.activemq mbean.
Select localhost --> Queue

Run the client few times and note the queue size.

How to deploy JSR181 annotated class in Apache Axis2

JAX-WS (Java API for XML Web Services) provides support for annotating Java classes with metadata to indicate that the Java class is a Web service. With the annotations, you can expose java classes as web services with minimum effort.
Apache Axis2 ships with JAX-WS support since its 1.4 release. This post explains the simplest possible scenario of JAX-WS support, how you can deploy an annotated class in Axis2.

Pre-requisites
Apache Axis2-1.4 or later
JDK1.5 or above

Step 1
Write an annotated class as follows.

package org.apache.axis2;

import javax.jws.WebMethod;
import javax.jws.WebService;

@WebService
public class Calculator {
@WebMethod
public double Add(double x, double y){
return x+y;
}
}

Here, the @WebService annotation tells the server runtime to expose all public methods on the above class as a Web service. Also, with the @WebMethod annotation, you can specifically denotes the methods which are exposed in the web service.

Step 2
Package the above class as a JAR (i.e:- Calculator.jar).
You need to create a directory in Axis2 binary distribution where the annotated jars are placed.
Therefore go to AXIS2_HOME/repository (AXIS2_HOME is where you extracted the binary distro) and create a new directory called, servicejars.

cd AXIS2_HOME/repository
mkdir servicejars

Step 3
Copy the annotated jar file to the servicejars directory. Then, start Axis2server (AXIS2_HOME/bin/axis2server.bat{sh})

Step 4
Go to http://localhost:8080
You will see that the calculator class will be exposed as a web service. Click on the service name.
You will be directed to the following URL and the WSDL of the service can be viewed there.
http://localhost:8080/axis2/services/CalculatorService.CalculatorPort?wsdl

Step 5
Service Deployement is over by now. Lets invoke this service using a client. I will use SOAPUI for the demonstration, you may choose any of the available mechanisms.

Open SOAPUI and start to create a new WSDL project.
Enter the above WSDL path(http://localhost:8080/axis2/services/CalculatorService.CalculatorPort?wsdl) as the initial WSDL.
Select the request, provide inputs and submit. You will get the expected results back.



You can find more information about Axis2 JAX-WS API from here.

Tuesday, September 23, 2008

WSO2 Data Services plugin for Eclipse WTP

WSO2 Data Services 1.0 provides you with a IDE plugin which can be integrated to Eclipse WTP. You can create and deploy data services to a remote or local data services server from IDE. This post demonstrates how a simple MySQL data service is created and deployed using Eclipse WTP.

Pre-requisites

Download and install WSO2 Data Services 1.0
Download and install Eclipse WTP

We will create a data service using MySQL. Please follow the instructions provided in WSO2 Data Services Quick Start Guide to create a data base and populate data.

Step 1

Download wso2 data services eclipse plugin (org.wso2.ws.dataservices.ide_1.0.0) from here and copy it to Eclipse_home/plugins directory.

Start Eclipse and select a new workspace. Select Workbench to go to the work bench.

Step 2
Open the new wizard selection window (File --> New -- Other). If you have copied org.wso2.ws.dataservices.ide_1.0.0.jar to the eclipse plugins directory correctly, you will see WSO2 Data service wizard option in there.



Select wso2 dataservice creation wizard and click on Next. The initial configuration screen of the Data Service Creation wizard will be displayed as follows.



Select Try it after deploying check box.
We are going to create a data service through IDE wizard and deploy it to a wso2 dataservice server running in localhost. (You can deploy data services to a remote server as well).
Therefore, you need to provide truststore and administrator credentials in that server.

Click on Set truststore. Browse for wso2carbon.jks which is located at your WSO2DS_Home/conf directory. (WSO2DS_HOME is the location where you unzipped wso2 dataservice 1.0 binary distribution)
You will be prompted to enter password for the trust store. Enter wso2carbon and click ok.

Click on Set Credentials to enter username and password of the target data service server.
Enter admin as the user name and password.

Click on Next to proceed through the wizard.

Step 3

Now you are at the step one of data service configuration wizard.
Give a name for the service (i.e:-IDEDataService)

Click on Add button to add a new data source. Since we use MySQL data source, select RDBMS as the data source type and click ok.

You will get a message saying "Currently typed database driver class does not reside in the class path. Please provide correct path to the jar file". Click ok.

Now you will be directed to the mySQL database configuration window.



Enter the following values for MySQL database configuration.

Driver Class = com.mysql.jdbc.Driver
JDBC URL = jdbc:mysql://localhost:3306/employeedb
Enter the user name and password of your MySQL db.

Enter jar path to driver class (mysql-connector-java-*-bin.jar). Then click on Test Connection button. You should get "Test Connection Successful" message.
Click "OK" to finish the database configuration.

Click "Next" in the WSO2 Data service wizard Step one to move to the next step.

Step 4

Now you should be in the step 2 of the wizard. Click on Add New Query. Following window will be displayed.



Select default data source. Enter the follwoing values for the rest of the fields.

Query ID = allEmployees

SQL Statement = select * from employee

Grouped by Element = employees

Row name = employee

Row namespace = http://test.org

Now click on 'New' button under 'Result (Output mapping)' window. 'Add New Output Mapping' window will be popped up. Add three output mappings as follows

  1. Mapping Type = Element

    output field name = id

    SQL Column Name = id

  2. Mapping Type = Element

    output field name = name

    SQL Column Name = name

  3. Mapping Type = Attribute

    output field name = address

    SQL Column Name = address

We have added one query to our data service configuration.

Click on 'OK' button at the "Query Configuration" window. You will be directed back to the step two of data service wizard and your new query will be listed there.

Click Next button to continue. Step three of the data service configuration wizard will be displayed.

Step 5

Click on 'Add New Operation' button. Enter a name for the operation (i.e: getAll) and leave the default settings and click ok.

By now, we have completed all data service cinfiguration steps. Click Finish to deploy the service.

(Make sure wso2 data service server instance is running in your host before finishing the IDE wizard. You can start it by running wso2server.bat located at WSO2DS_HOME/bin directory)

If all are correct you will get "Data Service deployed successfully" message. Also, a browser will be popped up withTryit page where you can easily test the service.

Sunday, September 21, 2008

How to use assertions in JMeter SOAP/XML-RPC sampler

Assertions are essential components in a JMeter test plan. They are very important in regression testing in which you can compare test results with a pre-defined output. 
As I explained here, JMeter Soap/xml-rpc request sampler can be considered as an one of the easiest mechanisms to test web services. 
Lets see how assertions can be added to a Soap/xml-rpc sampler so that you can use it easily in automated web services regression testing.

Before continue with this, you may go through  the following articles.

Step 1
In this example we are going to invoke the sample version service that ships with Apache Axis2.
Therefore, please download Apache Axis2-1.4.1 binary distribution from here and extract it in your file system.

Start Axis2server by runnning axis2server.bat{sh}

Step 2
Start JMeter by running jmeter.bat or sh.
Right click on Test Plan element and add a thread group.
Then add the SOAP/XML-RPC Request sampler element to the above thread group. 
(Add --> Sampler --> SOAP/XML-RPC Request)

Paste the following soap request in the Soap/XML-RPC Data section in the sampler.

<?xml version='1.0' encoding='UTF-8'?>
   <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
        <soapenv:Body>
       <ns0:getVersion xmlns:ns0="http://axisversion.sample"/>
      </soapenv:Body>
   </soapenv:Envelope>

Enter "http://localhost:8080/axis2/services/Version" as the URL.
Enter "urn:getVersion" for "Send SOAPAction".

Step3

Right click on the SOAP/XML-RPC Request sampler element and Add --> Assertions --> Response Assertion

Enter a suitable name for the assertion. 
Enter "Hello I am Axis2 version service" as the pattern to test.
Select "Text Response" as Response Field to Test.
Select "Contains" as the pattern matching rule. 



Step 4
Now we need to visualize the result of this assertion. Therefore right click on the Thread Group element and Add --> Listener --> Assertion Results

Run the thread group. If test is successful, you will not get any errors in Assertion Results. 
Change the pattern matching rule of the assertion in to "Matches" and run the test again.

You will see the failed assertion in assertion results view.


You can extend this test with more complex web services and add assertions accordingly. Then this can be executed in regression testing of your web services. 

Friday, September 19, 2008

QA role in Hackathons and Risk based testing

A few days back, we had a hackathon at WSO2 in order to resolve a large number of open bugs and boost the schedule of Data Services 1.0 release. A set of developers and QA team sat together and went through the open issues and eventually got more than 100 defects fixed and verified.
If you are familiar with hackathons or if you are a tester, you may certainly raise the following questions.
- What is the role of QA in a Hackathon
- How to deal with the regression issues and frequent builds

It certainly is a challenge to involve in testing and quality assurance during a hackathon. There is a high risk of breaking the features in between builds. However if you manage it properly, Hackathons are good opportunities for QA and testing teams to get more familiar with the AUT (Application under test) hence uncovering more and more bugs, learn and share the knowledge of practical use cases of products etc..

Lets try to find out answers for the above questions from QA user point of view.

What is the role of QA in a hackathon?

As defined in the wikipedia, Hackathon is an event when programmers meet to do collaborative software development. Testers, BAs, PMs and other astake holders may also take part in it.

The primary role of QA/test teams in a hackaton is reproduce the issues which were reported by them. This involves functional issues, cross browser issues as well as cross platform related bugs. The reporter of the bug knows the way to recreate it than any other.
This will greatly reduce the time to reproduce bugs and help developers to get them fixed effectively.
In most occasions, the AUT is started in debug mode in testers machines and someone familiar with the code, debug the source remotely to get the issues fixed quickly.

Whenever a bug is marked as resolved, testers get an update from source repository (in our case SVN), build the source and verify and close or reopen the bug.

Hackathons are ideal places to discuss the usage scenarios/patterns of the product being developed. QA/testers can identify more and more scenarios and apply them in testing. This help to uncover a lot of hidden bugs.

It is an essential for QA/testers to have and set the source code up in their IDEs. If you are familiar with the code and know the root cause of the issue, you are free to go ahead and fix the bug by your self. We did it and worked well :)
One of the most important requirement to have source with QA during a hackathon is, QA can go through a module with some developer and try to find out the places where bugs can be introduced. This glass box testing approach is one of the most important feature in a hackathon.

During a hackathon, QA find bugs and report it immediately to the relevant developer and get it fixed. QA should make sure to track all issues using the bug tracking system though some of the issues are reported verbally.

Dealing with regression issues and frequent builds

While fixing more and more bugs it is essential to ensure that the regression issue are minimum. Regression testing is the most difficult task for QA in a hackathon. Whenever a set of bugs are fixed, you get an update from source repository and build in your machine. Then you verify the bug and close it.
When you do this, there is a high chance to missing more and more regression issues. So, as a QA tester, how do you deal with it?

Before starting a hackathon, you should have a proper idea about the most critical features of the AUT. You should identify the areas which can cause most damages to the recognition of the product as well as for your customers. Then you should keep in mind that these critical features are not regressed in any new build use for testing. In other wards, though you test 4-5 new builds per day, you must ensure that the highly risked features are verified and tested properly.
Risk based testing is the most suitable approach to ensure the critical features are not broken during a hackathon.

It is important to get a few labeled builds for testing during a hackathon. We could not do this in Data service 1.0 hackathon though. We cannot guarantee the quality of the builds taken from users local repositories. Therefore, to make sure the AUT is in a proper state, it will be essential to have a labeled QA release built from a pure build environment and release for testing.

After all, Data Service 1.0 hackathon went really well and helped to deliver the product on time with acceptable quality!

Throttling request messages with WSO2 Data Services

WSO2 Data services 1.0 has been released now. This free and open source product consists of a lot of useful features which can be used to implement your SOA based systems with minimum effort.
Access throttling can be considered as a new and vital feature included in it.
In web services interactions, we usually have requirements to restrict number of requests our web services serve for a given client. Also, we need to allow service access to a specified domain or IP range.
WSO2 Data Services provides an easily configurable UI based utility to throttle messages targeted to a particular data service or a set of services.
This post will take you through a basic throttling configuration.

Pre-requisites
Download and install WSO2 Data Services 1.0

Step 1
Start server by running WSO2DS_HOME/bin/wso2server.bat{sh}
Access wso2 data service management console (https://localhost:9443/ds)
Log in to console with default admin credentials (admin/admin)
Select Data Services link in the left navigation menu. You will be directed to the Deployed Services page.
Click on the default service, CustomerService
You will see the following page.



Step 2

Click on Throttling link which is placed under Quality of Service in the above page.
Throttling Configuration for CustomerService Service page will be displayed.
Select "Yes" from Enable Throttling drop down.
Default throttling configuration will be displayed as follows.



In the above table, Range denotes the IP addresses and domains to be restricted.
Remove the second row of configuration table.
In this demonstration we will restrict accessing the default CustomerService to the requests originating from local host. Therefore you can leave "other" as the range "IP" as type.

There are three access levels.
Allow - All requests are allowed without applying any restriction for the specified range
Deny - Access is denied for all requests comes from the given range
Control - Restrictions are applied based on the given constraints (Max Request Count, unit time and prohibit time period)

In this demonstration, we are going to use "Control" access level. Hence, Change the Access level to "Control". Max Request Count, Unit time and prohibit time period text boxes will be enabled.

Enter 10 as Max Request Count. 100000 as Unit time and 20000 as prohibit time period.
This means, our sample data service (CustomerService) accepts only 10 requests from localhost during 100 seconds (100000ms) . If all 10 requests hits the server before unit time expires (before 100 seconds), no more requests are allowed in to the service within 20 seconds (20000ms) as specified in prohibit time period.

A more detailed explanation on these terms can be found in the inline help of WSO2 Data services management console.

Click on Finish button to save the throttle configuration.


Step 3

Our throttling configuration is over by now. Lets invoke the sample service 10 times and see how throttling works.
Go back to the service management page of the CustomerService and click on Try this Service link.
Select "customersInBoston" operation and click on "customersinBoston" button. Hit this button 10 times to send 10 requests to CustomerService.
Send one more request. You will receive a fault similar to the below.

Fault: Access deny for a caller with IP 127.0.0.1 : Reason : You cannot access this service since you have exceeded the allocated quota.

Monday, September 15, 2008

Getting started with WSO2 Data Services

As I mentioned in a previous post, WSO2 Data Services is now available for you to download and try out. WSO2 Data Services is an open source product and it is available under apache license.

The objective of this post is to get you start with WSO2 Data Services with minimum configuration steps. You can find more details of WSO2 Data Services solution from wso2.org online documentation

Step 1
Download and install wso2 data service solution. You may download the latest beta2 version from here. Just extract wso2-dataservices-1.0-xx.zip in to a directory in your file system.
We refer this directory as WSO2DS_HOME.

Step 2
Start wso2 data services solution. Go to WSO2DS_HOME/bin and run wso2server.bat{sh}

Step 3
WSO2 Data services provides a web service interface for data stored in relational data bases, csv or Microsoft Excel files. Since our intention is to get our first data service running as quicker as possible I will use a simple csv file as the data source.
Open a text editor and create a csv file as follows.

id,name,address
01,charitha,colombo

02,Michel,Dallas

03,John,Westborough


Save this file as employee.csv.

Step 4
Access WSO2 Data Services management console. Open a browser and go to http://localhost:9443/ds
Click on Sign-in link at the top right corner. Enter username = admin and password = admin as login credentials.
You will be directed to the home page of Data Services management console.



Step 5

Click on Add from the left navigation menu. The step one of data service creation wizard will be shown.
Enter csvservice as the Service name and click on Next.

Step 6

Select csv as the data source type and click on Add.


Step 7

In CSV Data source configuration window, enter the following values.
Id = 1
CSV File location = D:\temp\employee.csv
Column Seperator = ,
Starting Row = 2
Max. no of rows to read = -1
Headers Available = TRUE
Column Selection (You can click on the column names specified in the drop down. Then it will add column numbers according to the sequence of selection)
id as column no:1
name as column no:2
address as column no:3



Step 8

Click "Next" from the data service wizard step 2. You will be directed to the step 3 where you can create queries for the service.
Click on "New Query" button.
Add New Query window will be popped up. Enter the following values.

QueryID = q1
DataSource = 1
Grouped by element = emps
Rowname = emp

Click on "Add New output mapping" button. In "Add new Output mapping" window, enter the followings. (Repeat this with name and address columns as well)
Mapping Type = Element
Output field name = id
CSV Column ordinal = 1



Step 9

If query is configured as in the previous step, you should notice the following elements in the "Preview of Data service configuration" section.
<query id="q1" useConfig="1">
<result element="emps" rowName="emp">
<element name="id" column="1" />
<element name="name" column="2" />
<element name="address" column="3" />
</result>
</query>

Click on next button of the Data Service Step 3 to continue with the wizard. Step 4 will be displayed where the service operations are configured.

Click on Add New Operation button.
"Add New Operation" pop-up window will be displayed. Enter the following values.
Operation name = op1
Query = q1
Click OK

Now all the data service configuration steps are done. Click on Finsh button to deploy our CSV data service.

Step 10
csvservice will be added to the deployed services list in Deployed Services page.
Lets invoke our data service using the simplest service invocation mechanism and see we get the data stored in csv file as the output.

Click on csvservice. Service Management page will be displayed.
Select Try this service link.
Click on op1 button and you will get the results as follows.

Friday, September 5, 2008

How to avoid OutofMemory error when building projects with Maven2

You may have encountered outofMemory issues when building source with Maven2. This normally happens when Maven runs out of available system memory.
In such case you have to set MAVEN_OPTS environment variable to increase the available memory.

In Windows
Open a command prompt in which you build the source and enter the following options. (Change the memory size according to the amount of memory in your system)
SET MAVEN_OPTS=-Xmx1024m

In Linux
Open a shell and set the options as follows.
export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=128m"

Thursday, September 4, 2008

Data Services-1.0Beta - The latest member of WSO2 SOA middleware suite

We have been working hard over the last few weeks to launch the newset addition to the WSO2's SOA middleware platform, WSO2 Data Services -1.0beta. Now you can download it and explore the power of web services with relational data, data stored in csv or Microsoft Excel files. 
WSO2 Data Services provides a convenient and user-friendly mechanism to expose data as web services and utilize a lot of QOS features such as WS-Reliable Messaging, WS-Security etc..
It consists of a management UI which allows you to create, deploy and invoke data services without writing a line of code. Also, Eclipse IDE plugin brings the Data servce functionality into Eclipse IDE in which you can configure data services very easily. 

There are lot more things you can do with this new product and some of the helpful references were already published. You may begin with quick start guide.
Stay tuned. This blog will be updated with many how-tos on WSO2 data services soon.

Tuesday, September 2, 2008

One more browser to test against!

Browser compatibility issues are annoying. You cannot guarantee an application behaves similarly in all popular browsers without repeating the same set of tests in each of them. It is a headache!
To make the things worst for developers as well as testers, yet another browser has been added to the list.

Google recently announced the launch of their open source browser called Chrome. So, we now have one more browser to make our applications compatible with. Applications need to be designed in a way so that they work properly in all major browsers. Testers need to put some extra effort to make sure cross-browser issues are minimum. Also, UI automation tool kits should be made compatible with this new browser.

Google has released the beta on Windows first. Lets see what difference will this new browser make.

Sunday, August 31, 2008

How to use jconsole to monitor and manage WSO2 WSAS

Service or system monitoring and management are essential components of any SOA framework. WSO2 WSAS provides two different mechanisms to manage and monitor web services.
1. Ajax based GUI console
2. JMX based monitoring facility

In this post, I'm going to demonstrate the second option, JMX based service and system monitoring component. You can find more information about WSAS GUI console from here.

JMX (Java Management Extension) provides a set of tools and APIs for applying a standard client/server-based architecture to monitoring and management of a Java application.
J2SE version 5.0 adds core support for the Java Management Extensions (JMX) into the Java standard libraries. We are going to use Jconsole, included in jdk1.5 or newer versions, to explore the management and monitoring capabilities provided by WSO2 WSAS.

Pre-Requisites

Download and install WSO2 WSAS-2.2.1 or later

Step 1

JMX port is disabled by default in WSAS. Open WSO2WSAS_HOME/conf/server.xml and uncomment the following element.

<!--The JMX Port-->
<JMX>9999</JMX>

Step 2

Start WSO2 WSAS (run wso2wsas.bat or sh).

Make a note of the JMX url which will be printed on server startup console
i.e:- JMX Service URL : service:jmx:rmi:///jndi/rmi://YourHost:9999/server

Step 3

Start command prompt (or shell in linux), type Jconsole and hit enter. JConsole:Connect to Agent window will be popped up.



Enter JMX url (service:jmx:rmi:///jndi/rmi://YourHost:9999/server)
Enter admin as user name and password. Note that, any user with admin privileges can log in to JMX.
Click on Connect.

You will be directed to the summary page of Jconsole as follows.



Step 4

Click on MBeans tab. You will see the Mbeans tree in the left pane. Select org.wso2.wsas MBean.
ServerAdmin, ServiceAdmin and StatisticsService MBeans will be listed there.
Select ServerAdmin.



You will see shutdown, restart, restartGracefully, shutdownGracefully, startMaintenance and endMaintenance administrative functions when clicking on Operations tab in the above screen.

Step 5

We observed a few administrative function of WSo2 WSAS which were exposed through JMX in the above step. Lets see how service statistics are monitored using Jconsole.

Click on StatisticsService Mbean at the left pane. Next, select Operations tab.
Following screen will be displayed.



In order to check service statistics, we must invoke a service deployed on WSAS. Open your browser and enter the following URL.
http://localhost:9762/services/version/getVersion
This will send a HTTP GET request to the default Version service.

Now enter 'version' as the value of the getServiceRequestCount operation in above screen and click on getServiceRequestCount.
You will get '1' as the response.



Invoke Version service a few more times (just send http GET requests using the above URL).
Enter 'version' as parameter 1 (p1) and 'getVersion' as parameter 2 (p2) of getOperationRequestCount operation.
You will see a operation return value similar to the one bwlow.



Now, you will be able to proceed with more operations and get the statistics of server and system status.

Tuesday, August 26, 2008

How to avoid "java.security.InvalidKeyException:illegal Key Size" error when invoking secured services in WSO2 WSAS

"java.security.InvalidKeyException:illegal Key Size" error is a common issue which occurs when you try to invoke a secured web service in an environment where the provision for java unlimited security jurisdiction is not done.
This can be avoided by installing Java Cryptography Extension (JCE) unlimited strength jurisdiction policy files.

1. Suppose you are using jdk15. Go to http://java.sun.com/javase/downloads/index_jdk5.jsp

2. Go to the Other Downloads section and click on download link next to "Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 5.0"

3. Download jce_policy-1_5_0.zip and extract it in to a directory.

4. You will find local_policy.jar and US_export_policy.jar files there in the extracted directory. Copy these two files to $JAVA_HOME/jre/lib/security directory. (These files will already be there. you may replace them)

5. Restart WSO2 WSAS and invoke your secured service again. You will not encounter the "invalidkeyException" any more.

Wednesday, August 20, 2008

Six different mechanisms to invoke a web service

I recently published a tutorial at WSO2 Developers portal - Oxygen Tank, which demonstrates six different mechanisms to invoke a publicly available web service.
This tutorial explains each mechanism using a set of simple steps and mainly focused on beginners to the web services.

See the complete tutorial here

Friday, August 8, 2008

How to deploy Apache Axis2 on GlassFish Application Server

I have demonstrated the steps to deploy Apache Axis2 on BEA WebLogic, IBM WebSphere, JBoss and Resin application servers in my previous posts. This series is not complete unless the steps to deploy Axis2 on GlassFish server are explained.
Lets see how Axis2 can be deployed on GlassFish server. It is quite straightforward and similar to the other application servers we have discussed so far.

Pre-requisites:
Download and install the latest version of GlassFish server from here.

Step 1

Start GlassFish server.
i.e:- Go to GlassFish_Home/bin and run asadmin script as follows.
asadmin start-domain domain1

This will start GlassFish server in domain1.

Step 2

Download Axis2.war from here

Step 3

Access GlassFish administration console (In a browser, access http://localhost:4848).
Log in to administration console (Default username=admin, password=adminadmin).

Step 4

In the left navigation menu of the GlassFish admin console, select Enterprise Applications and click on Deploy.
You will be directed to the following screen.



Select 'Web Application(*.war)' as the Type from the drop down list.
Enter the location of the downloaded axis2.war.
Leave the other settings intact and click OK.

You will be directed to the "Web Applications" page.



Select Axis2 from the table and click on Launch.
Axis2 administration page will be displayed.

Step 5

Verify the status of installation. Click on 'Validate' link of Axis2 admin page. You should see the following 'Axis2 Happiness' page.



Now you can log in to Axis2 administration page and start deploying services.

Tuesday, August 5, 2008

How to use tcpmon inside Eclipse

Apache TCPMon is an utility that allows the messages to be viewed and resent. It is very much useful as a debug tool. If you don't know much about this tool, you can find more information here , here or here.

I found an extension of this great tool, which can be included as an Eclipse plugin so that developers can monitor message transmission within their workspace without opening a separate tcpmon instance. It is very cool indeed.

Saliya Ekanayake, a colleague at WSO2 has developed this utility as part of his university project. Lets see how this tcpmon plugin can be used in Eclipse WTP.

1. If you haven't done yet, download and install Eclipse WTP

2. Download tcpmonitor-1.0.0.jar from here

3. Copy tcpmonitor-1.0.0.jar in to Eclipse_home/plugins directory

4. Start eclipse

5. Select Window --> Show View --> Other --> Tcp Monitor --> TCP Monitor

6. Tcp monitor will be added as an view tab.



Now you can configure the necessary port settings and trace message transmission.

Thursday, July 31, 2008

Web application testing in Ruby(Watir) - 2 minutes guide

Watir (pronounced as Water) is a free open source tool which can be used to automate web applications. It is an extension of Ruby programming language. Unlike most of the other testing tools it gains the advantage of powerful features of Ruby and simulate browser interactions in very simple manner.
Lets see how a simple google search is automated using Watir in few steps.

Pre-requisites
Install Ruby (1.8.5-24 or later)

Step 1

Install Watir. Open a command window or shell and issue the following commands
gem update --system
gem install watir

The above two commands update gem installer and then install watir in your system.

Step 2

Open SciTE ruby editor or notepad and start to create the following script.

require "watir"

ie = Watir::IE.new

ie.goto("http://www.google.com")

ie.text_field(:name, "q").set("WSO2 WSAS")

ie.button(:name, "btnG").click


Step 3

Save the above file as SimpleTest.rb and run it from the command line by typing SimpleTest.rb
You will see that an Internet Explorer browser instance will automatically be popped up, access google, type "WSO2 WSAS" text and click on search button as a user interacts with the web site.

Step 4

Lets see what each of the above statements of our test script do.

require "watir" - This is similar to an import statement. This tells ruby script to use Watir as an extension library

ie = Watir::IE.new - Instantiate a new IE browser instance and open it

ie.goto("http://www.google.com") - Instructs IE instance to access google.com

ie.text_field(:name, "q").set("WSO2 WSAS") - Set text, "WSO2 WSAS" as the search query

ie.button(:name, "btnG").click - Click the "search" button

If you need to simulate web interaction with Firefox, you can use FireWatir, which allows to write test scripts for Firefox browser.

Wednesday, July 30, 2008

How to validate a WSDL using Eclipse

When you create a wsdl file from scratch or use an already designed one, you must make sure it is valid. In other words it should;
  • consist of well-formed XML (All tags should be closed and nested properly)
  • conform to XML Schema
  • comply with the rules and standards defined in WSDL specification
  • valid with the rules defined by WS-I (Web services interoperability organization)
Eclipse Web tools project (WTP) provides a very useful tool which validates a wsdl against above rules/standards.
Lets see how we can validate an existing wsdl using Eclipse wtp.

1. Download and install Eclipse wtp

2. Open eclipse IDE

3. Start to create a new wsdl (File --> New --> other --> Web Services --> WSDL)

4. Give a name to the wsdl (you can provide the name of wsdl which needs to be validated) and click on next. Accept the default options and click on Finish.

5. You will see a design view of a new wsdl file. Move to source view by selecting "Source" tab.

6. You will see an skeleton source of the new wsdl. Just remove it. (remove all elements in the wsdl)

7. Copy the contents of your existing wsdl (Suppose it is Myservice.wsdl) and paste in the source tab.

8. Save it by selecting save button in eclipse tool bar.

9. Right click on the wsdl file and select Validate

If your wsdl has errors, those will be shown in problems pane.

You may notice that we create a new wsdl, remove its content and copy the existing (already created) wsdl in to source view of wsdl validator. I suggest that as a work around because I could not find a way to import an existing wsdl directly into wsdl validator.

Tuesday, July 29, 2008

Apache JMeter book is published




There are no much books available on test automation and tools. In order to fill the void in the software testing bibliography, Emily H. Halili decided to put together the basic concepts of test automation and performance testing with JMeter.
This book was designed to pave the path for readers to get detailed insight on JMeter as well as a basic reference guide. I was the technical reviewer of this book. It consists of 140 pages and 8 chapters, starts with a short introductory chapter on advantages of test automation and requirements of automated tests.
Chapter 2 focuses on an overview of JMeter followed by setting up environment and installation.
Chapter 4, The Test Plan shows you all the parts of JMeter test plan. It explains all elements of test plan and how they interact together.
Use of Jmeter in load/performance testing is demonstrated in chapter 5. In chapter 6, you will get information on the tools in JMeter that support functional or regression testing.
Chapter 7 and 8 describe some advanced topics such as database servers, using regular expressions etc..

One of the many beuties of JMeter is that you don't need to have prior programming skills to use it, making JMeter one of the most popular open source testing tools in the testing community.
This book will definitely help testers as well as programmers, project managers to get better understainding on JMeter.
The book is an easy read and you should be able to complete most of the demos within very short time. I'm proud to be the reviewer of this book and I'd recommend this as a must-have item in book shelves of any QA/test engineer.
For more information, please visit Packt publisher's website.