Chapter 7. Go web services

 

This chapter covers

  • Using RESTful web services
  • Creating and parsing XML with Go
  • Creating and parsing JSON with Go
  • Writing Go web services

Web services, as you’ll recall from our brief discussion in chapter 1, provide a service to other software programs. This chapter expands on this and shows how you can use Go to write or consume web services. You’ll learn how to create and parse XML and JSON first, because these are the most frequently used data formats with web services. We’ll also discuss SOAP and RESTful services before going through the steps for creating a simple web service in JSON.

7.1. Introducing web services

One of the more popular uses of Go is in writing web services that provide services and data to other web services or applications. Web services, at a basic level, are software programs that interact with other software programs. In other words, instead of having a human being as the end user, a web service has a software program as the end user. Web services, as the name suggests, communicate over HTTP (see figure 7.1).

Figure 7.1. Comparing a web application with a web service

Interestingly, though web applications are generally not solidly defined, you can find a definition of web services in a Web Services Architecture document by a W3C working group:

7.2. Introducing SOAP-based web services

 
 
 
 

7.3. Introducing REST-based web services

 
 

7.4. Parsing and creating XML with Go

 
 
 
 

7.5. Parsing and creating JSON with Go

 
 
 

7.6. Creating Go web services

 
 
 

7.7. Summary

 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest