Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Cross-platform UI Development with Xamarin.Forms

You're reading from  Cross-platform UI Development with Xamarin.Forms

Product type Book
Published in Aug 2015
Publisher
ISBN-13 9781784391195
Pages 330 pages
Edition 1st Edition
Languages
Author (1):
Paul Johnson Paul Johnson
Profile icon Paul Johnson

Table of Contents (22) Chapters

Cross-platform UI Development with Xamarin.Forms
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
1. In the Beginning… 2. Let's Get the Party Started 3. Making It Look Pretty and Logging In 4. Making Your Application Portable 5. Data, Generics, and Making Sense of Information 6. A View to a Kill 7. Connect Me to Your Other Services 8. What a Bind! 9. Addressing the Issue 10. This is the World Calling… 11. A Portable Settings Class 12. Xamarin Forms Labs 13. Social Media into the Mix 14. Bringing It All Together Index

Chapter 7. Connect Me to Your Other Services

While Azure provides a very powerful mobile service, you may decide to connect to another type of service, such as one employing a RESTful interface or using the Windows Communications Framework (WCF). Both are very different. In this chapter, we will look at both.

In this chapter, we will:

  • Use a RESTful interface for a web service

  • Look at a WCF interface for a web service

Let's take a REST


Before we look at the interface, we need to understand what REST is. In its simplest terms, REST is a set of six constraints, which when applied to an architecture (such as a web service) gives the basis of the RESTful style.

While it is outside the scope of this book to look at the architecture, there are many very good websites that cover what REST is. As far as we're concerned, we are interested in communicating with the web service.

REST services are typically transmitted using HTTP's GET and POST methods and return data in plain XML.

POST and GET

The best way to think about the difference between POST and GET is to consider a standard mail. If you have something to send, you POST it. If you receive something, you GET it.

So far, it's easy

When we receive the information from the server, it is typically in XML. This is a plain text format in a serialized format (which is a form of formatting that takes the objects being sent by the server and creates a plain text inline list...

The Windows Communication Framework


To use the WCF, you must first have a file known as a generated client class. This class for use with a PCL must be created using the Silverlight Svsvcutil binary that comes as part of the Silverlight SDK. A similar named binary (svcutil) comes as part of the Windows SDK. Do not use this binary because the client class produced cannot be used in the PCL. The client class can only be generated on a Windows machine (or on a virtualized Windows machine).

Note

The code for this section is available in Chapter 7/WCF.

For this, I've chosen to use Microsoft's VirtualEarth service. To use this, you will also need to generate a temporary key. This key is similar to a Google Maps key or the OpenWeatherMap API key, which is needed when communicating with the service to authenticate who you are. The key is free. When you create the key, ensure that the key is a trial key and the type is Other Public Mobile App. Copy the generated key and store it in the public readonly...

Summary


There isn't anything difficult in connecting to the other types of service available, be it RESTful, WCF, or anything else available (within reason). The difficulty typically comes with setting up the interface for the outside world.

In the next chapter, we'll look at one of the most powerful aspect of the forms development: data binding. It's not as bad as you'd think and is incredibly powerful.

lock icon The rest of the chapter is locked
You have been reading a chapter from
Cross-platform UI Development with Xamarin.Forms
Published in: Aug 2015 Publisher: ISBN-13: 9781784391195
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}