Monday, April 4, 2011

Working with Web Services

"Web services" is a paradigm that allows the development of loosely coupled applications composed by several modules which interact through well-known and widely adopted protocols, e.g. SOAP and HTTP.
Web services allows to orchestrate several modules [perhaps provided by different developers] in one single process known as workflow.
A workflow is then a special kind of application which integrates software components who expose their functionality through the web service description language, WSDL.
May be you are wondering if a particular development platform is necessary for creating web service-based applications. The answer is NO. Any platform able to understand (reads and writes) SOAP messages, it is also able of interacting with any other platform to speak the web service language. Therefore, web service is a framework to leverage the integration of multiple software stacks, operating systems + programming languages.
Despise diverse technologies which have been developed to support this paradigm, this entry would focus on a widely known Java-based software stack Apache Tomcat + Axis2. Tomcat is an application container and Axis2 is the framework to process SOAP messages.

How to install tomcat + axi2
Download the most recent version of Apache Tomcat. Apache Tomcat is a Java-based application container to support different technologies such as Servlets and JSP. (Check References section)

For Axis2 is highly recommended to download the .WAR distro. The war distro provides an easy way to deploy web services.

How to write/deploy a web service
There are different ways for deploying Java web services. Right here, and only for demostration purposes, the deployment and execution of POJO-based classes is presented.

Write a usual Java class, for instance HelloWorld.class.
class HelloWorld {
  String sayHello(String name) {
     return "Hello " + name;
  }
}

Compile the file and copy the class file into the ${TOMCAT_CONTAINER_DIR}/webapps/axis2/WEB-INF/pojo directory. If 'pojo' does not exist, please create it.

[Re-]run your tomcat container and check the available services. The HelloWorld service would be listed.


References
  • Apache Axis2 Web Services - An introductory tutorial is accessible in this link.
  • Tomcat - Version used during this tutorial was Apache Tomcat 7.0.8
  • Apache ODE - Orchestration Director Engine
  • BPEL - Business Process Execution Language
  • Eclipse - Helios release was used during this tutorial


No comments: