How to Move Your Line of Business Apps to Phone + Cloud

phone7-brandRob Tiffany has put together a series of blog posts describing how to move data to your Phone applications from the cloud. Issues for your apps include slow service connections. For device apps to be successful, they must pre-fetch the data they need and cache it offline so a user can keep working when the network is not around.  This is not typical SOA, calling Web Services on-demand to help drive your application.

And you’d like to be able to connect to data in Windows Azure or on your on-premises database, store it on the Phone so you can have a disconnected story too. And you want to do this efficiently.

If you’ve looked at the Networking in Silverlight for Windows Phone 7 documentation on MSDN, you might have noticed that a number of things are missing, such as WCF RIA Services, WCF Data Services (OData), Duplex Communication over HTTP, Sockets, UDP Multicast Client, NTLM Auth, RSS/ATOM Feeds, Custom Bindings, JSON Serialization.

So what is left? How does that work?

And what are the steps, trick, and tips? Here’s the view:

Step 1. Build a WCF REST + JSON Service

Rob’s article describes what is on the Phone, in particular SOAP and REST + Basic Authentication. And he makes the case of JSON as a preferred data format for the wire. Next he shows how to build out a sample Web Service and how to add the attributes so your data is serialized. He writes the class that holds the data in a way that can be used on both Windows Phone and on your server.

He defines the contracts for a public interface for the Web Service that will generate JSON on the server. And he provides code to get all or a part of the list of data from the Web Service. He finishes off the service with the configuration files that set up the server to provide data using REST.

See Building a WCF REST + JSON Service.

By the way, this solution works whether you are hosted on Windows Server or Windows Azure.

Step 2. Move Your Web Service to Windows Azure

Using Visual Studio 2010, the Azure Development Fabric and SQL Server, Rob shows show you how to move this code to the cloud. He takes you through each step, with screenshots. He shows you how to startup your project, how to rewrite the default services contract and web.config file to work with WCF REST and JSON. He explains how to give the Windows Phone 7 caller a web-friendly Uri to call.

And then to test and debug the Azure-based Web Service. And you’ll see the data returning the data objects in wireless-friendly JSON format.

See Moving your WCF REST + JSON Service to Windows Azure.

Step 3. Consume You Web Service on the Phone

Rob begins by leveraging the Web Service code to create a Phone app that cpnsumes the Web Service. Next he shows how to build your Phone application in Visual Studio that will access the Web Service in Azure all on your development computer.

He illustrates how your Phone application will make an asynchronous call to the Web Service, and how to store the data on the Phone. He uses a Database class to connect to an ObservableCollection and the DataContractJsonSerializer used to de-serialize JSON-encoded Customer objects that are downloading over the air.

And finally, he shows how to access the table of your in-memory database.

See Consuming an Azure WCF REST + JSON Service.

Step 4. Working with the In-Memory Database

In this post, Rob shows how to query this new in-memory database using LINQ and I’ll show you how to save the data in your local tables to Isolated Storage so you can keep using your apps even when the network has disappeared.

He walks you through each of the steps to do CRUD (create, retrieve, update, and delete) your data using a listbox and buttons on the Phone. And then how shows how to store and retrieve the data from IsolatedStorage.

See Working with an In-Memory Database.

Enjoy.

Bruce D. KyleISV Architect Evangelist | Microsoft Corporation

cid:image010.png@01C9DEED.1FDB2200 cid:image011.png@01C9DEED.1FDB2200 cid:image012.gif@01C9DEED.1FDB2200 channel9