Manage Learn to apply best practices and optimize your operations.

REST with Axis, Struts, ColdFusion and WCF

The popularity of REST style programming is causing older development frameworks like Axis, Struts, ColdFusion and WCF to add REST support.

Starting with the relatively simple XML-RPC (remote procedure call) protocol ten years ago, frameworks and standards for Web services have steadily gotten more complicated. For some time, SOAP has seemed to have a lock on developer thinking while open source and commercial frameworks to support these evolving ideas have steadily grown into larger and more complex packages. As a reaction to increasing complexity, the REST (representational state transfer) style has gotten increasing developer mindshare. I thought it would be interesting to examine how the frameworks that got started before REST became popular have responded to this trend. First let's look at what the ideal REST style implies.

Degrees of REST compliance
As described in Fielding's dissertation, the REST style emphasizes Web resources and the URI address to access the resource. This is opposed to SOAP and XML-RPC orientation which emphasizes setting a process in motion that creates a resource. REST style proponents contend that the uniform interface of simple HTTP methods and headers lets you create services that are simple and easy to expand.

The HTTP1.1 protocol standard, RFC 2616, authored by Fielding and other experts, has very clear advice on how the methods should be used. The standard emphasizes that GET, HEAD, PUT and DELETE requests should be idempotent – that means that multiple identical requests should have the same effect as a single one. Many Web applications tend to ignore this requirement for the GET method.

Here is a summary of how strictly RESTful services should handle HTTP methods. I found that most of the older frameworks are just making a start on complying with this style.

  • GET - Retrieve a representation of a resource in a specified representation (Internet media type).
  • POST - Use the data in the request body to modify a resource. The URI identifies a resource that will handle the enclosed data.
  • PUT - The body of the request creates or sets the current state of a resource identified by the URI.
  • DELETE - Deletes a specified resource on the server.
  • HEAD - Retrieve information on the state of a resource such as the date last modified in the form of HTTP headers. The intent being to provide a way for a program to avoid an extra GET if the resource has not changed.

Apache Software Foundation - AXIS
An early toolkit originally created by IBM as SOAP4J found a home at the Apache Software Foundation as the SOAP project. However, it was not long before the need to support emerging standards such as WSDL prompted a redesign called Apache Axis, released in 2002. The current version, Axis 1.4 is still in use.

The next redesign, Axis2, started while the first Axis was still being developed. There is great potential for confusion when speaking of the Axis toolkits because both Axis and Axis2 are simultaneously in use with "version 1.4" the latest for both lines. Axis2 is intended to support more of the evolving SOAP, WSDL, and WS-* standards with a faster and more flexible architecture. Axis2 version 1.4 supports RESTful services with a bit of a kludge that falls short of full REST support.

Digging into the documentation, we find that Axis2 support for a RESTful GET is accomplished by reformatting a REST style URL into a SOAP request that is forwarded to the normal SOAP request processing with the response in an XML format that does not include the normal SOAP envelope. While this is sufficient for Ajax style support of XML consuming rich Internet applications (RIAs), it does not handle other resource types an application might need and there is no provision for use of the PUT and DELETE methods.

Apache Software Foundatiion - Struts
Apache Struts is one of the most popular open source frameworks for creating Java Web applications in the Struts 1 version. However, it appears that the complete redesign known as Struts 2 will be the place to look for REST style request support. There is a "REST Plugin" for Struts 2.1.1, which apparently is still in beta testing, that will make it easy to support REST style requests using Ruby on Rails style mapping of URLs to code.

The ColdFusion Framework
ColdFusion was one of the first (1995) Web development frameworks. Now owned by Adobe Systems, it is mainly aimed at creation of database driven Web sites with ColdFusion Markup Language. The latest, version 8, has provision for handling query style GET and POST requests and returning data to rich client applications in JSON or XML formats. However, interpretation of URI style requests is not supported. The ColdFusion engine can run in either the Java J2EE server or the .NET server environment.

Microsoft's Web service toolkits
Researchers at Microsoft pioneered the development of SOAP Web services and the SOAP protocol has been well supported in the various Microsoft development environments. Rather than a gradual evolution of existing frameworks, Microsoft has created a new one. The latest framework from Microsoft is the Windows Communication Foundation or WCF. This is a generalized Web services stack for building connected systems using the Microsoft .NET Framework. The emphasis is still on supporting SOAP and the WS-* standards, but the latest (.NET 3.5) version now provides for creating services that can be configured to be addressed in either SOAP or REST style. Provision is made for supporting the GET, POST, PUT and DELETE HTTP methods. While the examples I found emphasize return content types of JSON (JavaScript Object Notation) and XML, mechanisms are provided for recognizing requested content types and creating the correct response.

Conclusion
Generally speaking, the older frameworks have been undergoing major redesigns in the last few years to keep of with the pace of new developments so your old framework may come up with innovations to let you get started with RESTful Web services. However, if you are not already committed to a framework you might take a look at the totally new approaches I discussed in recent articles. Frameworks like Jersey and IBM's Project Zero don't carry any excess baggage from previous approaches.

References
The beginning of Web services with XML-RPC.

Apache Axis2 home page

Creating a RESTful Web service with the Windows Communcation Foundation API

Apache Struts framework home page

The RFC for the HTTP1.1 standard


This was last published in May 2008

Dig Deeper on REST and microservices

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchSoftwareQuality

SearchCloudApplications

SearchAWS

TheServerSide.com

SearchWinDevelopment

DevOpsAgenda

Close