Introduction

Between the Java web services libraries and the newer Scala libraries and frameworks that are available, Scala easily handles web service tasks. You can rapidly create web service clients to send and receive data using these general libraries, or solve problems with more specific libraries, such as creating a Twitter client with the Twitter4J library. There are also several good JSON libraries available, so you can easily convert between data JSON strings and Scala objects.

When it comes to creating your own RESTful web services, you can use lightweight frameworks like Scalatra or Unfiltered and have web services up and running in a matter of minutes. But you have many choices, so you can also use the Play Framework (Play), Lift Framework, or other Scala libraries to create web services, as well as all of the previously available Java web service libraries.

As demonstrated in Chapter 16, Scala has nice support for the MongoDB database, and this chapter demonstrates how to provide a complete web services solution using Scalatra and MongoDB. This chapter shares a few recipes that are specific to using Play to create web services.

Finally, although the Scala libraries offer some nice convenience classes and methods for connecting to web services, the trusty old Java Apache HttpClient library is still very useful, and it’s also demonstrated in several recipes.

Get Scala Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.