Over a million developers have joined DZone.

Mango Sample: A Cloud-based Phone App in 5 Minutes!

DZone's Guide to

Mango Sample: A Cloud-based Phone App in 5 Minutes!

· Cloud Zone
Free Resource

MongoDB Atlas is a database as a service that makes it easy to deploy, manage, and scale MongoDB. So you can focus on innovation, not operations. Brought to you in partnership with MongoDB.

When you create a Windows Phone application you might have some data to store. Where do you store it?

  • Well, there’s always Isolated Storage. I discuss that here
  • There’s always a local SQL Database. I discuss that here.

But, what if on-the-phone isn’t good enough? …to the cloud! I discuss that here [there’s no link because this is the article! :)].

Why the cloud?

There are lots of great reasons. Here are a few:

  1. Your data needs to be updated or refreshed, call the cloud
  2. Your data needs to be saved for roaming users, call the cloud
  3. Your data is huge and phones only need a bit, call the cloud

Before you do anything, you might want to check if there’s even a network to use. To detect the network, WiFi, and so much more, read this article.

Service References

Creating a Service Reference to some remote Web Service is a snap.

MSDN: The Internet is host to an extensive variety of web and data services that you can use in your Windows Phone applications to create compelling new user experiences. This topic introduces networking and web services, and describes the primary classes and utilities that you can use for building web-integrated Windows Phone applications. [snip/] Because the vast majority of web services published on the Internet are based on HTTP, you can use the HttpWebRequest and WebClient classes to access web services from Windows Phone applications. To help ease the task of generating the additional code that web services often require, you can use the Silverlight Service Model Proxy Generation Tool (SLsvcUtil.exe) or the Visual Studio Add Service Reference feature to generate a proxy class.

Security Consideration

When connecting to a web service that requires an application key, do not store the application key with an application that will be run on a device. Instead, you can create a proxy web service to authenticate a user and call an external cloud service with the application key. For more information about security recommendations, see Web Service Security for Windows Phone.

Let’s see it!

In the video featured on my blog, we’ll create both the phone application and the web service.

I create a service-based Windows Phone application. I’m the kind of guy who likes to have samples be simple so I can get the technique without having to understand some complex back story. Hopefully, that rings helpful for you like it does for me. Here are the key steps:

  1. Create the Windows Phone application project
  2. Create the Windows Communication Foundation (WCF) service application
  3. Implement the logic in the WCF service
  4. Add a Service Reference to the WCF service in the WP application
  5. Implement the UI in the WP application
  6. Call the service and watch the magic


Adding cloud services to your windows phone application can add a lot of flexibility and power to your application. The better your application, the less likely users will hit that UNINSTALL button – after all, that’s what we are working against, here, right?

A few gotchas to remember:

  1. Using the cloud means you need a network
  2. The user might be out of signal reach
  3. The user might be in airplane mode
  4. Be a good bandwidth user – don’t overdo it

Adding a Service Reference creates the asynchronous proxy code for you – then, as the developer, the rest it up to your creativities.

Best of luck!


MongoDB Atlas is the best way to run MongoDB on AWS — highly secure by default, highly available, and fully elastic. Get started free. Brought to you in partnership with MongoDB.


Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}