That’s the title of my speaking on an event entitled “SMILE 2.0”. SMILE 2.0 was held at Universitas Pendidikan Indonesia, Bandung, on March 13, 2010, which is a successor of the first SMILE held a year ago.

Yes, my name and topic is not on the banner since I was told to speak just a week earlier. But I can prove you that I was there and talked on the event by these photos :)
The audience
The speakers and committee
Let’s jump to the topic. Honestly, it’s quite heavy to be consumed by college students. It’s not fun at all, contrary with the tagline of the event, “Microsoft for fun” (I think it’s supposed to be “Microsoft technologies for fun”). However, I think it’s my responsibility as IT practitioner and entrepreneur to update them with the latest trends in IT business, that is hopefully encouraging them to prepare for the future. I focused on one of IT trends in 2010 (and years before), which is cloud computing. Anyway, I did demoing something fun to close the show, which is developing mobile application to work with WCF data service.
Back to cloud computing, it is all about on-demand internet-based computing which enables users and developers to produce and consume services without the knowledge of, or having to spend efforts and costs to maintain the technological infrastructure that supports those services. Take for example Microsoft’s cloud computing platform, Windows Azure, which offers among other things a data service through its Windows Azure Storage. It allows developer to produce and consume data services without having to know how to actually store and manage the data. One of supported data is Windows Azure Table which is the structured storage supporting massively scalable tables in the cloud. One of its enabler technology, used for exposing and consuming the table data, is Windows Communication Foundation (WCF) Data Services.
WCF Data Services is formerly called ADO.NET Data Service, which formerly called Astoria. It is basically a Microsoft’s RESTful implementation for data-centric services on the web. In fact, it’s the first Microsoft’s technology that fully embrace REST architecture and implement the latest standard for data sharing over the web, “OData” or Open Data Protocol. WCF Data Services allows other technologies like Microsoft SharePoint 2010 to publish its list and libraries in RESTful way.
Why changing the name you ask? Read here. WCF Data Services naming will be formally used with the release of .NET 4.0 and Visual Studio 2010. So, you’ll expect WCF Data Service when you add a new item on a web project. It’s there on Visual Studio 2010 RC, I think it’s not there on Beta 2.
Some new features of WCF Data Services on .NET 4.0, and also currently publicly available on .NET 3.5 SP1 by applying Data Services Update for .NET 3.5 SP1, can be watched here. I write the list here:
- Projections: This feature extends the WCF Data Services URI format by adding the $select query option to enable clients to explicitly define the properties to be returned.
- Data Binding: The data services client library for the .NET Framework 3.5 SP1 has been extended to support two-way data binding.
- Row Count: As the feature name suggests, it allows returning the total number of entities in a set by counting it on the server-side, instead of retrieving the entities to the client and counting it on client-side.
- Feed Customization (aka "Web Friendly Feeds").
- Server Driven Paging (SDP).
- Enhanced BLOB Support: This feature enhances the BLOB support provided in V1 to enable data services to stream arbitrarily large BLOBs, store binary content separate from its metadata, easily defer the loading of BLOB content when its metadata is requested, etc.
- Request Pipeline
- New "Data Service Provider" Interfaces for Custom Provider Writers.
OK, let’s get started to create a WCF Data Service. In my speaking, I did a showcase that uses architecture like this:
Are you wondering what icon on the left side of Data Services Client? More story about that later.
Creating WCF Data Service
As described above, WCF Data Service is about data service over the web. So, to create one you need to create website/web application project on Visual Studio. I’ll use VS 2010 RC. Walkthrough:
1. Create a Web Application project
File –> New –> Project
VS 2010 will create a Web Application project with a bunch of folders and files you might not need them, including Account folder (for storing login pages), Style folder (CSS file) Site.master (master page), . Don’t be scare to erase them as right now we only focus to WCF Data Services.
2. Create an Entity Data Model
Right Click on your project in Solution Explorer and select ‘Add New Item’, choose ‘ADO.NET Entity Data Model’ and give your model a name:
You’ll face a Wizard to generate entity from database or creating empty model. Select the first one and Next. then, select the database and specify connection string name to be stored in web.config. I’ll use the “Northwind” database, and NorthwindEntities for connection string name which will be also used as the name of main entry class to work with database using ADO.NET Data Framework.
Select the database objects to generate for your model, for example: Categories, Customers, Order Details, Orders, Products, and Shippers. Give the namespace for generated model classes, I’ll use Northwind.Model.
Done. You’ll have Entity Data Model for Northwind database.
3. Create a WCF Data Service
Again, “Add New Item” to the project. This time, select WCF Data Service and name it Northwind.svc, for example.
It will generate two files: Northwind.svc and Northwind.svc.cs. Northwind.svc.cs contains a class which represents the skeleton of data service. Change it to something like this:
1: using System.Data.Services;
2: using System.Data.Services.Common;
3:
4: namespace WcfDataServiceTest
5: { 6: public class Northwind : DataService<NorthwindEntities>
7: { 8: // This method is called only once to initialize service-wide policies.
9: public static void InitializeService(DataServiceConfiguration config)
10: { 11: // TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
12: // Examples:
13: config.SetEntitySetAccessRule("*", EntitySetRights.All); 14: //This is new in ADO.NET Data Service v1.5 and WCF Data Services in .NET 4.0
15: config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
16: config.UseVerboseErrors = true; //for debugging-purpose only
17: }
18: }
19: }
4. Now, test the Service
Right click to Northwind.svc file and View in Browser. You should have something like this:
Let’s test to query data by writing this URL on IE address bar: “http://localhost:1281/Northwind.svc/Categories”. You’ll have:
Consuming the Data Service
Now, the service is up and running, it’s time to consume it from client. Several months ago, I posted an Excel-based Office Business Application (OBA) to work with WCF Data Services. For this demo, and I showed on my speaking, I’ve written a sample Microsoft Word 2010-based OBA/VSTO. The app looks like this:
When I click to an input or content control beside the Customer ID, a customer data grid view will be displayed on action pane . Selecting a row on that data grid view will fill the content control. By this mechanism, I don’t have to fill Customer ID input by typing it. That is the good way to implement list of values inside office application.
When I click to Product Table, a Product data grid will be shown on action pane. I can use it to select ordered product. By clicking a product row, Product Table will be filled with Product ID, Product Name, and Unit Price. All you have to type is Quantity. Cool huh? :)
I will not write the detail about how to implement this application. Please download the source code below and start to play around with it.
Presentation slide:
I’ll write more postings about consuming the WCF Data Service from other platform/technologies. Just stay tune.