Writing RESTful web services using a CICS Liberty JVM server - Part 1
Introduction
My name is Daniel Fitzgerald, I'm a trainee software developer in the CICS team based at IBM Hursley UK. I've been working for the last six months on the Mobile Extensions Feature Pack V1.0 for CICS Transaction Server. As part of the project we looked at using JAX-RS, JSON and RESTful designs within Liberty. This article, coming in two parts is the result of these investigations.
The CICS Liberty server is a web container technology based on WebSphere Application Server Liberty Profile. It comes as part of CICS TS V5.1 at no extra cost and offers the potential for significant zAAP offload compared to a regular CICS Web Service. The CICS Liberty server offers a lightweight Java container with all the features of Java Servlets and JavaServer Pages (JSP's) as well as local access to your existing CICS applications and data. You can expose these existing resources to the web using Java Servlets hosted in the CICS Liberty server and design them in a RESTful way. But before we begin what exactly is REST?
The term 'REST' refers to Representational State Transfer, a design pattern for interacting with resources stored in a server. Each resource has an identity, a data type, and supports a set of actions. The RESTful design pattern is usually used in combination with HTTP, the language of the internet. In this context the resource's identity is its URI, the data type is its Media Type, and the actions are made up of the standard HTTP methods GET, PUT, POST and DELETE.
REST vs SOAP
Now we understand what REST is, why would we want to use it? Why not use Simple Object Access Protocol (SOAP)?
-
RESTful designs tend to be simpler, easier to understand and work much more closely to the way the web works.
-
By using HTTP headers to describe the data we are exposing we save on overheads incurred by the SOAP envelope.
-
SOAP and Web Services Description Language (WSDL) are designed to be machine-readable, RESTful URI's should be human readable and describe the data being exposed. This makes testing and debugging simpler and easier.
-
RESTful designs put the onus on the client to remember state and by careful use of the 'Expires' HTTP header can improve caching while reducing server-side complexity.
-
Using a RESTful design works well with JSON (JavaScript Object Notation) – a data interchange format that can be much less CPU intensive to parse than the equivalent XML.
Business cases
Whilst you decide if a RESTful architecture is for you, let's consider some business cases:
-
You want to modernize the interface to your application by replacing terminal screens with a Web browser and a RESTful client.
-
You want to use Java based tools to develop, package and deploy web solutions using existing CICS applications and resources to ease development and speed up time to deployment.
-
You already use the Liberty profile technology but want to see how running it in CICS will offer added benefits. These include easy access to local CICS resources and co-location with your data source such as DB2.
JAX-RS
A quick note on exactly what JAX-RS is. It stands for Java API for RESTful web services and is used for designing web services according to the Representational State Transfer (REST) design pattern. It uses annotations to convert between Java and web data. There are many implementations of JAX-RS in use today including the CICS Liberty Server, WebSphere Application Server and Apache Wink.
Conclusion
In the next part of the article I'll discuss the actual implementation of such a service including packaging and deployment to the CICS Liberty server complete with screenshots and code samples.
Tags: 
jaxrs
json
cics
web_services
blog
restful
liberty