Xamarin.Forms apps can consume web services implemented using a wide variety of technologies. A new guide on consuming and authenticating access to web services using Xamarin.Forms has recently been published. The guide describes how to communicate with different web services in order to provide create, read, update, and delete (CRUD) functionality to Xamarin.Forms applications, and how to integrate authentication services into Xamarin.Forms applications in order to enable users to share a back-end while only having access to their own data. Topics covered include:
- Communicating with ASMX services, WCF services, REST services, Azure Mobile Services, Amazon Web Services, and Parse services.
- Using basic authentication with a REST service.
- Using the Xamarin.Auth component to authenticate against OAuth identity providers.
- Using the inbuilt authentication mechanisms offered by Azure Mobile Services, Amazon Web Services, and Parse services.
To understand the sample code provided with the guide you should be familiar with the basic principles of web services, Xamarin.Forms applications that use XAML, and asynchronous programming using Tasks. For more information see Introduction to Web Services, Getting Started with Xamarin.Forms, and Async Support Overview.
Where to start?
The suggested reading route for the guide is as follows:
Exploring the guide
The guide includes the following topics:
Understanding the Sample
This topic provides a walkthrough of the Xamarin.Forms sample application that’s used to demonstrate how to communicate with different web services. Topics covered include the anatomy of the application, the pages, data model, and invoking web service operations.Consuming an ASP.NET Web Service (ASMX)
ASP.NET Web Services (ASMX) provide the ability to build web services that send messages over HTTP using Simple Object Access Protocol (SOAP). SOAP is a platform-independent and language-independent protocol for building and accessing web services. Consumers of an ASMX service do not need to know anything about the platform, object model, or programming language used to implement the service. They only need to understand how to send and receive SOAP messages. This topic demonstrates how to consume an ASMX web service from a Xamarin.Forms application.Consuming a Windows Communication Foundation (WCF) Web Service
WCF is Microsoft's unified framework for building service-oriented applications. It enables developers to build secure, reliable, transacted, and interoperable distributed applications. There are differences between ASP.NET Web Services (ASMX) and WCF, but it is important to understand that WCF supports the same capabilities that ASMX provides — SOAP messages over HTTP. This topic demonstrates how to consume an WCF SOAP service from a Xamarin.Forms application.Consuming a RESTful Web Service
Representational State Transfer (REST) is an architectural style for building web services. REST requests are made over HTTP using the same HTTP verbs that web browsers use to retrieve web pages and to send data to servers. This topic demonstrates how to consume a RESTful web service from a Xamarin.Forms application.Consuming an Azure Mobile Service
Azure Mobile Services is a scalable mobile application development platform that enables the functionality of mobile applications to be enhanced by using Azure. This topic, which is only applicable to Azure Mobile Services that use a JavaScript back-end, explains how to use the Xamarin component for Azure Mobile Services to query, insert, update, and delete data stored in a table in an Azure Mobile Services instance.Consuming an Amazon SimpleDB Service
Amazon SimpleDB is a web service that provides the ability to store and query data in Amazon's cloud. This topic explains how to use the AWS SDK for .NET to query, create and replace, and delete data stored in a SimpleDB service.Consuming a Parse Service
Parse provides backend solutions for mobile applications, eliminating the need for writing server code and maintaining servers. This topic demonstrates how to consume a Parse web service from a Xamarin.Forms application.Authenticating a RESTful Web Service
HTTP supports the use of several authentication mechanisms to control access to resources. Basic authentication provides access to resources to only those clients that have the correct credentials. This topic demonstrates how to use basic authentication to protect access to RESTful web service resources.Authenticating Users with an Identity Provider
Xamarin.Auth is a cross-platform SDK for authenticating users and storing their accounts. It includes OAuth authenticators that provide support for consuming identity providers such as Google, Microsoft, Facebook, and Twitter. This topic explains how to use Xamarin.Auth to manage the authentication process in a Xamarin.Forms application.Authenticating Users with Azure Mobile Services
Azure Mobile Services uses a variety of external identity providers to support authenticating and authorizing application users. Permissions can then be set on tables to restrict access to only authenticated users. This topic explains how to use Azure Mobile Services to manage the authentication process in a Xamarin.Forms application.Authenticating Users with an Amazon SimpleDB Service
Amazon SimpleDB does not offer its own resource-based permissions system. Instead, authentication against an identity provider can be used to ensure that users only have access to their own data in the SimpleDB domain. This topic explains how to restrict users' access to their own SimpleDB data.Authenticating Users with a Parse Service
The Parse .NET SDK provides classes to add user management and access control lists to an application. This topic demonstrates how to add user account functionality to a Xamarin.Forms application, and how to use access control lists to limit data access to the creating user.
Exploring the samples
Along with the guide there are also sample apps that demonstrate the concepts explained in the guide:
TodoASMX
This sample demonstrates a Todo list application where the data is stored and accessed from an ASP.NET Web Service (ASMX).TodoWCF
This sample demonstrates a Todo list application where the data is stored and accessed from a Windows Communication Foundation (WCF) web service.TodoREST
This sample demonstrates a Todo list application where the data is stored and accessed from a RESTful web service.TodoAzure
This sample demonstrates a Todo list application where the data is stored and accessed from an Azure Mobile Service instance.TodoAWS
This sample demonstrates a Todo list application where the data is stored and accessed from a SimpleDB service in Amazon Web Services.TodoParse
This sample demonstrates a Todo list application where the data is stored and accessed from a Parse web service.TodoAzureAuth
This sample demonstrates a Todo list application where the data is stored, accessed, and authenticated from an Azure Mobile Service instance.TodoAWSAuth
This sample demonstrates a Todo list application where the data is stored and accessed from a SimpleDB service in Amazon Web Services, with authentication occurring with a Google login.TodoParseAuth
This sample demonstrates a Todo list application where the data is stored, accessed, and authenticated from a Parse web service.