Chapter 5. Web services

 

This chapter covers

  • Using HTTP from Ruby
  • Building REST services with Rails
  • Using REST services with ActiveResource
  • Using SOAP with SOAP4R

Throughout this book, we show you ways of integrating Ruby with different applications and services. Some scenarios depend on a particular protocol or architecture, such as using Lightweight Directory Access Protocol (LDAP), sharing data through a relational database, or moving messages around with WebSphere MQ (WMQ). In this chapter, we’ll explore the web architecture and look at how we can use web services across language, platform, and application boundaries.

To this end, we’ll focus on Service Oriented Architecture (SOA) with Ruby. SOA is not a particular product, technology, or protocol—it’s an architecture for building services with the intent to reuse them in different contexts and combine them into larger applications. In this chapter, we’re going to choose common protocols and message formats and discuss three common styles for building web services: plain HTTP, REST, and SOAP.

First, we’ll cover the foundation and show you how to use HTTP and URLs. Then we’ll venture into the world of RESTful web services and show you how to handle resources, representations, and the uniform interface. Finally, we’ll talk about SOAP and using SOAP4R as a means for integrating with services developed around the SOAP stack, and in particular J2EE and .Net applications.

5.1. Using HTTP

5.2. REST with Rails

5.3. SOAP services

5.4. Summary