Welcome to MSDN Blogs Sign in | Join | Help

Welcome to Live Mesh!

Roman Batoukov
Windows Communication Foundation (Compact Edition) and the story of the Lunch Launcher

A while ago, when .NetCF v1 wasn't released yet, we could only guess what kind of applications our customers would build. People on the team were coming up with various ideas of mobile applications they would like to build on top of our platform and try to figure out which platform features would be most valuable. We had application building days, when everyone on the team would go and work only on their personal application projects.

One of the really simple ideas that came up then and remained unimplemented was the "Lunch Launcher". Many folks on the team prefer local restaurants to Microsoft cafeteria. Getting several people to go out to the same place often requires lots of coordination over the phone or e-mail, especially when people are away from their offices, in different buildings. Usually someone wants Indian food, someone had Indian three days in a row and wants to go for Mexican and someone else have strong cravings for a slice of bad pizza...

As most people on the team have some sort of Windows Mobile device connected to WiFi or mobile carrier network, we thought it would be nice to have an application that allows one person to send a lunch invite with a list of a few good local restaurants to other people and let them vote where to go to. When the poll is finished, its' results (the place of choice) are communicated back to everyone and everyone hopefully is heading to the same place. Sounds trivial, doesn't it?

However there are a couple of problems that make this application idea really hard to implement using existing connectivity technologies. First of all, how do I address someone else's device? Device IP address is not stable and is not discoverable... This makes "push" scenarios and true P2P not feasible.  Second, devices lose connectivity all the time and someone may be off-line when the message is sent. How do I make sure my message reaches the other person's device, if we may not be on-line at the same time?

Interesting enough, simple, well-known technologies exist today that can help solve both of these problems. Every connected Windows Mobile device can send and receive e-mail, i.e. it has a stable, discoverable address associated with it - e-mail address. E-mail also works pretty well in the on-line/off-line scenarios (occasional connectivity).  So, at some point Mike Zintel started promoting an idea of using e-mail as a web service transport and putting a programming model on top of it.  Hmm, e-mail!? I was really skeptical about this at first, as probably many of you are now. But let me ask you this - how many times did you use e-mail to transfer some data from one computer to another?  I find myself doing this far too often. For example, when I need to get some document from my machine at work to read it later at home - I send it as an e-mail attachment to myself. If I want to get a couple of pictures from my home computer to my work machine - I send myself an e-mail. I even use e-mail to get documents from my desktop machine to my laptop, when my laptop is off-line. It's quicker than sharing the file, turning another machine on, going to the share and copying it over. Sure, there are some limitations. But there are a number of scenarios when it comes pretty handy. Now, you may ask what does it have to do with .NetCF and web services and how does this help application developers?

Well, .NetCF team has been very busy since we shipped CF 2.0. A number of exciting things are happening here.  Earlier Mike gave away some "hints" about what's coming: "the NET CF team is working on WCF subset for the next release, with some interesting support for transiently connected networks." I think it's time to elaborate on what that really means.

We are bringing a subset of WCF (Windows Communication Foundation, formerly known as Indigo) to devices. WCF provides a new unified programming model for building connected applications with managed code. The cool thing I like the most about WCF is its' extensible channel architecture. It allows building applications that can work on top of completely different transports and protocol channel stacks. Using WCF programming model, now I can send and receive data in my application equally easily using HTTP, TCP or e-mail.  In many cases I can maintain identical or very similar communication logic code - sending and receiving the data works on top of various channels (only the initialization part will be different, as different channel stacks need to be constructed).

Compact WCF architecture

WCF is built around the concept of a Message object. The structure of a Message object loosely represents a SOAP envelope, and consists of two distinct parts: the message's body and an extensible collection of headers. The body is application-defined data, and headers are added/processed by infrastructure (and can also be used by the application). It is this structured primitive which is the core of WCF power (and which departs from the classic networking primitive of a byte array). It allows for extensible interoperable protocols to be built, and combined together in different ways. (See the following blog entry for more details).

The WCF programming model support will be limited to channel layer messaging (no service model support on the device) which means your program will be sending and receiving messages and it will be up to the application to correlate messages with each other (no RPC semantics). However, we are working on a custom proxy generation tool (along the lines with SvcUtil) that would allow consuming WCF services running on the desktop by the messaging client on the device without the need to modify the public-facing service.

Transport Channels perform the actual send/receive of the Message to a network resource. Layered Channels perform a function based on the Message passed in, and then delegate further modification and transmission to other channels in the channel stack. Some examples of Layered Channels include Protocol Channels that use Message headers and infrastructure Messages to establish a higher-level protocol (such as WS-Security). .NetCF will support a subset of WS-Security to enable message-level security and mutual certificate authentication.

We'll expose all necessary extensibility points so people could plug in their own transport and layered channels, while maintaining a unified programming model. We'll deliver a couple of transport channels out of the box, but we expect the community to fill in the gaps and build a variety of custom channels. The channels we plan to deliver out of the box are Http and... yes, e-mail (for WCF on desktop and device). Our friends from WCF team played around with building custom e-mail transport channel before and proved that it's feasible. We decided to take this experiment one step furhter to address concrete problems mobile application devlopers are facing today.

Thanks to the e-mail infrastructure, now you can host a service app on any machine or device that can reach your e-mail server (Exchange). It provides a totally symmetric communication model. Exchange server acts as a relay that allows communicating between devices that aren't on-line at the same time. We built a demultiplexing scheme that allows multiple applications to share the same e-mail account (the only limitation - multiple instances of the same application sharing the same e-mail account can't be on-line at the same time. Think of this as a network port sharing problem).  This works through firewall/NAT boundaries. And with AirSync "Always Up To Date" technology, it should allow prompt message delivery once network connectivity is available. We are going to leverage powerful Exchange 12 web services under the hood on the desktop side  Thanks to WCF layered architecture, channel implementation details will be hidden from application developers.We are working with Exchange server team to make overall user experience nicer and enable separation of regualr e-mail traffic from "service" e-mail traffic.

So, finally we were able to build a "Lunch Launcher" app. We also built some interesting P2P casual games (like Poker), that tolerate the high latency of the transport. We see this channel as a powerful notification mechanism for mobile LOB applications - now you can easily "push" important notification messages to occasionally connected device on the mobile network.  For example, a Mobile Sales application could easily push information about an item recall or inventory change to all devices in the field. Even if some of them are off-line, they'll pick up the message once the network becomes available:

I can also see this channel used as a light-weight notification mechanism to trigger more heavy weight data sync (through SQL Everywhere / Sql merge/replication or RDA) and avoid expensive polling.

We don't expect people to always use e-mail as a primary transport channel, if a good stable network connection is available. However, in many cases it can be used as a backup.  Thanks to the unified programming model, switching from one transport channel to another is fairly easy. The e-mail channel will provide an off-line message store on the device, so application developers won't need to implement complex logic to detect network connectivity. Thus app developers can just call Send() and forget about the message - it's placed into the off-line queue (Outbox) and gets physically sent out when it becomes possible.

We'll leave it up to you to come up with more cool app ideas. And we'd love to hear from you what kind of mobile WCF applications you'd like to build. As usual, your feedback is very important to us.

Stay tuned...

- Roman

This posting is provided "AS IS" with no warranties, and confers no rights.

Posted: Saturday, October 21, 2006 3:59 AM by romanbat

Comments

Nick Randolph's .NET Travels said:

With the next wave of .NET technologies almost upon us we need to spare some thought about what kind...

# October 30, 2006 4:38 PM

Alberto Silva said:

Nesta artigo um pouco longo do blog de um membro da equipa da .NET CF, mas que vale a pena ler com atenção,

# October 30, 2006 6:20 PM

Alberto Silva said:

Nesta artigo um pouco longo do blog de um membro da equipa da .NET CF, mas que vale a pena ler com atenção,

# October 30, 2006 6:23 PM

Impersonation Failure said:

Well the .NET CF team certainly haven't been sitting idle since they shipped CF 2.0. Roman Batoukov's

# October 31, 2006 12:30 AM

FrankPr's R@ndom Th0ughts said:

Roman Batoukov vom Compact-Framework-Team schreibt in seinem Blog über einige interessante Pläne für

# November 7, 2006 3:39 AM

Vibro.NET said:

Well, I guess a lot of people waited for this . Being able to write WS-* apps on phone? THIS IS GREAT!!!

# November 21, 2006 6:15 PM

Robert McLaws: Windows Vista Edition said:

Microsoft (and by "Microsoft" I mean an employee who has posted to his blog three times in the last two

# November 21, 2006 8:13 PM

Tecnologie .NET (Dotnet) said:

WCF Compact Subset Windows Mobile

# November 22, 2006 1:33 PM

Hugo Batista said:

Remember this? Now read this...

# November 22, 2006 3:16 PM

Johan Lindfors said:

Det här är en av de saker som jag fått absolut flest frågor om de senaste åren som jag varit ute och

# November 27, 2006 9:35 AM

wmugperu said:

Si pueden dar un vistaso lo que el equipo de NETCF está preparando con WCF den una mirada aquí. Post...

# December 16, 2006 11:30 PM

Smartymobile said:

Si pueden dar un vistaso lo que el equipo de NETCF está preparando con WCF den una mirada aquí

# December 16, 2006 11:30 PM

Smartymobile said:

Si pueden dar un vistaso lo que el equipo de NETCF está preparando con WCF den una mirada aquí . Mas

# December 16, 2006 11:30 PM

Giuseppe Guerrasio said:

Una delle domande più ricorrenti riguarda la possibilità di disporre del supporto di Windows Communication

# January 3, 2007 4:12 AM

Mighell's blog said:

Questa èdecisamente una notizia interessante: Una delle domande più ricorrenti riguarda la possibilità

# January 3, 2007 7:29 AM

Pablo M. Cibraro (aka Cibrax) said:

The .NetCF team is working on a subset of WCF for the next version of the compact framework. Today I

# January 8, 2007 10:05 AM

Sam Gentile said:

Completely buried with two projects and the main one is going to CTP #2 at a major back in Paris/London

# January 10, 2007 1:47 PM

Mehran Nikoo's Blog said:

Just another fantastic product from Apple . Although phones based on Windows Mobile are getting more

# January 11, 2007 3:34 PM

Bob Li said:

介绍 .NET Compact Framework V3.0 将提供的对 WCF 的支持,分析了 WCF 在移动设备上应用的场景和困难,以及在 WCF 中通过 EMail 方式进行通信的原理。

# March 17, 2007 7:13 AM

Hugo Batista said:

Remember this ? Now read this ...

# March 21, 2007 8:40 PM

Mark Prentice said:

This BLOG continues my discussion into new features of .NET Compact Framework 3.5 by diving into Windows

# March 26, 2007 8:50 PM

David Kline said:

Yesterday, Mark Prentice posted an introduction to the Windows Communication Foundation for .NET Compact

# March 27, 2007 2:27 PM

Mark Prentice said:

Lets continue the discussion of the .NET Compact Framework new WCF features by discussing the new EMAIL

# April 25, 2007 6:05 PM

David Kline said:

Yesterday, Mark posted a 'Hello World' example using the Store and Forward Messaging technology which

# April 26, 2007 2:12 PM

Innovation needs Passion said:

It's coooooooool, Amazing, its blew away my mind...  Hats off to NET CF team.... the exciting things

# April 29, 2007 1:52 AM

Марат Бакиров [MS] said:

Как мы знаем, на .NET compact framework поддерживается WCF. Я хотел бы упомянуть

# August 10, 2007 8:17 AM

Марат Бакиров [MS] said:

Рассказывается, как товарищи умудрились сделать мобильное p2p приложение на осно

# August 10, 2007 9:18 AM

外部部落格 said:

This BLOG continues my discussion into new features of .NET Compact Framework 3.5 by diving into Windows

# August 12, 2007 6:03 AM

外部部落格 said:

Lets continue the discussion of the .NET Compact Framework new WCF features by discussing the new EMAIL

# August 12, 2007 6:04 AM

David Kline said:

Several years ago, when I first joined the .NET Compact Framework team, we took some time (a week, if

# September 7, 2007 6:44 PM

Andrew Arnott said:

With the .NET Compact Framework 3.5 release which comes with Visual Studio 2008, a new Windows Communication

# October 29, 2007 3:53 PM

fox23 said:

对于Windows Mobile来说,WCF是一个崭新的概念,在.NET CF v3.5中提供了对WCF的支持,它是桌面WCF(Windows Communication Foundation,也称作Indigo)的一个子集。本文阐述了Compact WCF的功能和模型以及如何使用WCF轻松创建通信程序。

# March 28, 2008 3:28 AM

Hugo Batista: Software Architecture and Engineering said:

Remember this ? Now read this ...

# April 2, 2008 9:59 AM

Welcome! said:

It’s been 1.5 years since I published my last blog entry . It was about the fundamental problems mobile

# May 1, 2008 7:01 PM
Anonymous comments are disabled
Page view tracker