Chapter 17. Networking with SOAP and RESTful services

 

This chapter covers

  • Networking basics
  • Working with SOAP services
  • Using REST services, shared models, and MVVM
  • Serializing JSON and XML

It’s rare to find an app that doesn’t use resources out on a network. We live in a world of connected applications. Even apps as benign as games often phone home with metrics and usage data, high scores, update checks, ad metrics, and much more. For an application platform to be considered viable, it must have first-class networking support.

In this chapter, we’ll first take a quick look at the networking APIs available for use in WinRT and .NET 4.5. From there, we’ll dive right into learning about integrating with SOAP services. Even though SOAP services are on the decline, you’ll still run into them, and for some types of procedural operations, they’re the best choice.

Once we clean up with SOAP,[1] we’ll move on to a network-friendly implementation of MVVM, this time without using any MVVM toolkit. We’ll then use that MVVM implementation to structure the code we’ll use when integrating with an ASP.NET Web API RESTful service. That service may return XML or JSON, so we’ll also dive into how to manage serialization and deserialization with those two formats. But, before we can get going with services, let’s look at the basics, starting with downloading a file and setting up the site you’ll use throughout the rest of the chapter.

1 Oh yes I did!

17.1. Networking basics

17.2. Sharing your model

17.3. Consuming SOAP services

17.4. Structuring your client code using MVVM

17.5. Consuming data from RESTful services

17.6. Deserializing JSON and XML data

17.7. Updating data using PUT, POST, DELETE, and more

17.8. Summary