views:

72

answers:

5

This morning, I feel stupid. I created a simple WCF service, just compiling and running the default WCF Service Application (.NET 3.5). I then tried adding a service reference to a Windows Phone 7 application but got a warning:

Custom tool warning: Endpoint 'WSHttpBinding_IService1' at address 'http://localhost:50133/Service1.svc' is not compatible with Silverlight 3. Skipping...

My searches for a "getting started" guide to making web services for Windows Phone 7 seems to all end on articles about how great WCF RIA Services are and how unfortunate it is that they don't work (yet) for Windows Phone 7.

My goal was to use either LINQ to SQL or Entity Framework in a WCF Service to make a service that my Windows Phone 7 applications will access. This service could be hosted on a shared hosting provider, so I have little control over IIS settings, thus I even considered making .asmx services. I could also host it in Azure if easy and not to expensive.

I know this is a rather subjective question, but what path should I take? What is the simplest and recommended way to build the "service side" of a Windows Phone 7 application? If it is WCF, what's wrong with what I tried above?

A: 

There is only one technology to use for developing web services on the .NET platform - WCF.

You probably need to learn a little about WCF instead of Googling. In particular, you probably just need to use basicHttpBinding instead of wsHttpBinding (the default). You would never find that unless you took the time to learn what a binding is, and what bindings are supported by Silverlight.

John Saunders
+1  A: 

I highly recommend using OData with WP7. You can get started by downloading the WP7 OData SDK from http://odata.org. There are lots of programming resources and samples on the web including

The first 2 are especially helpful videos from MIX10.

HTH!
Chris

Chris Koenig
+2  A: 

The hands-on lab on channel 9 titled "Using Push Notifications" walks you through creating a WCF service and connecting to it using a Windows Phone 7 Silverlight application.

You can find the lab including the source code at: http://channel9.msdn.com/learn/courses/WP7TrainingKit/WP7Silverlight/UsingPushNotificationsLab/

And I agree with John that you probably just need to use basicHttpBinding instead of wsHttpBinding.

TechPreacher
+1  A: 

Hi Martin,

The latest guidance I've seen on this topic is by Rob Tiffany at Tech Ed in his WPH306 talk.

A very straight forward approach is offered with some good techniques for operating in the partially connected environment offered by the mobile platform.

Also the relative merits of transporting data using JSON, OData, XML are examined with good clarity.

ps: if you'd like to support bringing WCF RIA Services to WP7, feel free to checkout this post if you haven't already.

Mick N
A: 

You can use an MVC 2 website and JSON responses to build a lightweight services API for your site without the need for the overhead of WCF or adding any ClientAccess files.

The downsides are that you will need to duplicate the code to serialize your responses into a Win Phone 7 class library. I have some full fledged examples of using an MVC 2 website including authenticating requests using a key/secret architecture.

Jacob