WCF, Data Services & RIA Services Alignment Questions and Answers

Windows Communication Foundation (WCF) is the heart of the Microsoft Developer story around services. WCF is the unified programming model for working with services in the enterprise and across the Internet in .NET applications.


As highlighted in sessions at this year’s PDC, .NET Framework 4 makes it easier for developers to work with services from their managed code applications. With .NET 4, the WCF technology provides several different types of services to start from, based on your particular needs, but they all share the same underlying infrastructure. 


%u00b7 SOAP Services – Allows full flexibility for building operation-centric services. This includes industry standard interoperability, as well as channel and host plug-ability. Use this for operation-based services which need to do things such as interoperability with Java, be consumed by multiple clients, flow transactions, use message based security, use transports or channels in addition to HTTP, or host in processes outside of IIS. WCF has supported SOAP services since its initial release in .NET Framework 3.0, and .NET 4 adds additional WS-* support and default bindings to make it easier than ever to build SOAP services using WCF.


%u00b7 WebHttp Services – Is best when you are exposing operation-centric HTTP services to be deployed at web scale or are building a RESTful service and want full control over the URI/format/protocol. Support for HTTP services was added to WCF in .NET Framework 3.5 and generally referred to as “WCF REST”. A number of significant improvements, such as content negotiation have been added in .NET Framework 4.


%u00b7 Data Services -Data Services are best when you are exposing your data model and associated logic through a RESTful interface; it includes a full implementation of the Open Data (OData) Protocol for .NET (more on this below) to make this process very easy. . WCF Data Services was originally released as ’ADO.NET Data Services’ with the release of .NET Framework 3.5 SP1;


%u00b7 Workflow Services – Is best for long running, durable operations or where the specification and enforcement of operation sequencing is important. Workflow services are implemented using Windows Workflow Foundation (WF) activities that can make use of WCF for sending and receiving WCF-based service requests.


%u00b7 RIA Services – is best for building an end-to-end Silverlight application. WCF RIA services will be released with Silverlight 4, and is built upon WCF.


The important thing to remember is that each of the above service options builds on the WCF service model and should not be thought of as binary choices. These service options provide developers with a starting point that makes the job of accomplishing common tasks much easier; allowing any of the above services to be customized and extended using the power of the same WCF service model. We expect many applications will leverage multiple models for building out their applications and their developer’s knowledge will easily transfer from one model to the other, allowing developers to use one skill set across solution types.


So what does this mean to you as a developer? It means that WCF can be conceptualized using the following stack diagram:



Also of note in the above diagram is the appearance of the Open Data (OData) Protocol in the protocol box of the channel model. The OData Protocol made its initial splash as the protocol used by the Data Services programming model to present and interact with data. It is a protocol that defines how a client can query, navigate, and make changes to data in an open, RESTful manner. Data Services fully implements this protocol today, and RIA Services will (soon) expose an endpoint that supports this protocol.


Feedback from folks at PDC, after the sessions and at the booth, was very positive. General comments was that this made service development in .NET much more straightforward, changing the decision from ’which .NET technology do I use?’ to ’which part of WCF fits best to what I want to do?’ Today, This also provides more messaging consistency to products that share a common technology foundation. Over the coming years, this indicates the direction towards tighter technical consistency for the .NET developer.


That being said, we did receive a bunch of common questions at PDC; and we thought it was worth sharing them, along with the answers, here.


Why did we rebrand ADO.NET Data Services and .NET RIA Services at PDC? And how do they relate to WCF?


You told us that it was confusing having different communication technologies being built and shipped by different groups. In this case, ADO.NET Data Services (also known by the codename ’Astoria’) was falling under the ADO.NET brand and coming out of the Data group, while.NET RIA Services was being built and shipped with Silverlight. At PDC, and with the release of .NET Framework and Windows Server AppFabric, we are working to better align and simplify the developer experience on the .NET stack. This rebranding is the first step in bringing better alignment and simplification to the .NET communication stack that is WCF. Unifying these services offerings around WCF allows developers to use one set of skills when using services, in the short term this means being able to use these different service types with a dramatically shortened learning curve, and the long term this means getting full reuse of skills and code as the entire stack is aligned for these two technologies.


Technically speaking, these technologies share the same underlying programming model provided by WCF, but they are designed to meet different use cases. Data Services focuses on exposing your data model and associated logic through a RESTful interface, and RIA Services focuses on building end-to-end Silverlight applications.


Both WCF WebHTTP Services and WCF Data Services expose RESTful Services; how do they relate to one another?


The WebHTTP Service and Data Service technologies both share the same underlying programming model provided by WCF, but they are intended to meet different use cases. WebHTTP services are focused on operation-centric HTTP services to be deployed at web scale or when users are building a RESTful service and want full control over the URI/format/protocol.


Data Services on the other hand are focused on exposing your data model and associated logic through a RESTful interface. Today, Data Services is where you’ll find the richest implementation of the Open Data Protocol (OData), though in future releases of the .NET Framework, we plan on bringing OData support, as well as the declarative data model of Data Services, to WebHttp WCF Services.


How does a developer decide what service type my client should use to communicate with my Service?


If you are writing a “RIA Services Enabled” Silverlight application, the RIA Services tooling will automatically create the right client components for your RIA Services Domain Service.


If you are writing a client to an existing Service using Visual Studio, use “Add Service Reference” and the right client will be selected for you; a WCF Data Services Client for accessing a WCF Data Service or a WCF Client for accessing a WCF SOAP Service. Users can also use “Add Service Reference” to a WCF RIA Services Domain Service.


Are we deprecating any of these service types {SOAP Services, RIA Services, Data Services or Workflow Services}?


No; all of these technologies are core to our vision moving forward and each has a clearly defined use case for developers today. By bringing them all together within WCF, we provide developers with a clear place to start when building and using services. We also provide the developer with a collection of common concepts and extensibility point across these technologies, allowing you to be quickly productive using technologies with simple starting points while providing a powerful foundation should you need additional flexibility of the larger WCF stack.


If you are using one of these stacks today, we would like to reassure you that it still makes sense for you to continue to use what you are developing with. The stacks will get improved in the future, and the continuing unification story will provide you with additional benefits of the others, but none of these stacks are currently planned for deprecation.


If a key value proposition of RIA Services is its simplicity, how is this balanced with the flexibility for WCF?


WCF is a very powerful and flexible technology. What RIA Services provides is a prescriptive pattern that defaults many of those options for the best experience in the common cases. Early feedback on RIA Services has been that it makes it extremely easy to get an end-to-end solution up and running, by effectively hiding a lot of the WCF flexibility.  However, if need arises, developers are able to configure a RIA Services Domain Service like any WCF service with all the power and expressiveness they have come to expect from WCF. 

WCF extensions: The type ‘x’ registered for extension ‘y’ could not be loaded.

Quick note: if you configure a custom extension in WCF, don’t forget to add it as a reference to your project. If you don’t configuration will run just fine, but at runtime, the following exception occurs:

System.Configuration.ConfigurationErrorsException: The type ‘x’ registered for extension ‘y’ could not be loaded. (config information, line z)

   at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)
   at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
   at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
   at System.Configuration.ConfigurationManager.GetSection(String sectionName)
   at System.ServiceModel.Configuration.ConfigurationHelpers.UnsafeGetSectionFromConfigurationManager(String sectionPath)
   at System.ServiceModel.Configuration.ConfigurationHelpers.UnsafeGetAssociatedSection(ContextInformation evalContext, String sectionPath)
   at System.ServiceModel.Configuration.ServicesSection.UnsafeGetSection()
   at System.ServiceModel.Description.ConfigLoader.LookupService(String serviceConfigurationName)
   at System.ServiceModel.ServiceHostBase.ApplyConfiguration()
   at System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses)
   at System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses)
   at Microsoft.Tools.SvcHost.ServiceHostHelper.CreateServiceHost(Type type, ServiceKind kind)
   at Microsoft.Tools.SvcHost.ServiceHostHelper.OpenService(ServiceInfo info)

ASP.NET 4, ASP.NET MVC, and Silverlight 4 Videos of my Talks in Europe

[In addition to blogging, I’m also now using Twitter for quick updates and to share links. Follow me at: twitter.com/scottgu]

Hope you all had a great holiday – welcome to 2010!

Last month I did a blog post about some of the presentations I did in Europe and posted the slides+demo files from them.  High-quality videos of the talks I did in Sweden were posted two weeks ago on the Channel9 site, so you can also now watch videos of the talks online as well.  The videos use a nice format where you can watch me talking as well as the screen at the same time.  The code is readable when running in full-screen mode.

Below are links to the different talks along with the slides+sample files:

ASP.NET 4 and VS 2010 Web Development

This 90 minute talk provides a nice introduction to ASP.NET 4 and VS 2010 for Web Development.  It is primarily demo-driven and walks-through a lot of the new features coming with the release. 

The talk starts with a 2 minute introduction of someone introducing me which is in Swedish – but the rest of the talk is of me talking in English.

ASP.NET MVC

This 2 hour talk provides a nice introduction to ASP.NET MVC, and explains it by walking through how to build a simple application with it from scratch.  Along the way it highlights and discusses some of the new features coming in ASP.NET MVC 2. 

Silverlight 4

This 60 minute talk recaps the keynote I gave at PDC.  It walks-through the new Silverlight 4 features and capabilities.

Hope this helps,

Scott

MVP Again

MVP Again

Thanks to the Microsoft team for granting me a third straight BizTalk MVP. I suspect that they keep doing this just to see what regrettable statements I’ll make at the next MVP Summit. Either way, it’s an honor to receive, and I’m grateful for the perks it has to offer.
I need to get ready for […]

Reprocessing SAP IDocs through BizTalk Server using WE19

Reprocessing SAP IDocs through BizTalk Server using WE19

First off this technique should work with any RFC connected system but since the only RFC connected system that I use is  BizTalk it will therefore have some BizTalk specific information.

I have touched on this topic before in my web cast and in my blog that integrating with SAP can be tough due to the vast differences in terminology, process and technologies used.  A situation that I have come across is that you often need a Subject Matter Expert (SME) or someone very familiar with a Business Process to generate an IDoc for a BizTalk developer to test or validate their portion of the integrated application.  Sometimes creating an IDoc is very simple where as sometimes it may take a few transactions and screens to generate the IDoc in order to validate one of your use cases.  This can lead to some frustration by both the BizTalk Developer and SAP resource as the BizTalk developer is always bothering the SAP resource to create “just one more IDoc”.

Something that a colleague brought to my attention was an SAP transaction called WE19 that allows you to re-process an existing IDoc.  This allows the BizTalk developer to have the SAP resource create an initial IDoc and have the BizTalk developer re-submit that IDoc however many times they would like.  Another benefit of this is process that involved deltas.  We have a process where SAP will provide a “dump” of employee data that we need to update a down stream system with.  We don’t need to process this data every day so we will just send the differences, or deltas, on a regular basis.  So, even in a test or staging environment, once I have received the IDoc that contains all employee data I will not get that data again unless I ask for it.  If we have not had any changes to our employees I will also not get the delta information either since there is no new data to feed the downstream system with. 

Using this transaction is great because I don’t need to bother anyone from the SAP side to create data for me.  All I need to know is when the last time that particular IDoc was sent.  I can find this information in BizTalk by querying tracked message instances or by querying WE02 in SAP.  Once I find this information I need to capture the IDoc number as this piece of information is required in order to resubmit the IDoc.

Here are 3 different ways to find an IDoc number.  The first two involve BizTalk and the last involves using the WE02 transaction in SAP.  You may want to check with your BASIS administrator if you do not have access to the WE02 transaction.

  • Option #1 Obtaining the IDoc number from BizTalk Admin by viewing the message context property
    • Use a Tracked Message Events query from BizTalk 2009 Admin console and right mouse click on the IDoc that you previously received and select “Message Details”

image

    • Click on the “Context” caption

image

    • Observe the “DOCNUM” value and record it (unfortunately you can’t copy or paste from this screen)

image

 

  • Option #2 Saving IDoc message to disk and then inspecting context document.
    • Once again find the particular IDoc that you are looking for by running a Tracked Message Events query from BizTalk 2009 Admin Console.  Once you find this message, right mouse click and select “Save to File”

image

    • Navigate to the folder that you saved these message to and open up the XML file that contains all of the message context information

image

    • Once again locate the “DOCNUM” property and copy that value

image

 

  • Option #3 Use SAP transaction WE02 to locate your IDOC

image

    • Right mouse click on row and select “Copy Text”.  Note it will copy all text in row.

image

 

Resubmitting the IDoc

  • Now that you have the IDoc number using one of the approaches above you can navigate to SAP transaction WE19, populate the “Existing IDoc” field and click on the clock with the green checkmark in the upper left hand corner(underlined in red) .

image

    • The selected IDoc will then be displayed and then click on the “Standard outbound processing” button

image

    • You now have the ability to provide the number of instances of this IDoc that you would like sent so you can use this as a load testing tool for BizTalk as well.  Click the green checkmark to proceed.

image

    • You should now see a successful message indicating that the IDoc has been re-sent.

image

 

Summary

I know I have found the WE19 transaction to be very helpful so hopefully you will find it helpful as well. It can be pretty frustrating when you have a deadline and there is no one around to create IDocs for you.  Using this approach will lessen your dependency on having a SAP resource around.  You can also use this same technique to load up BizTalk with messages and test the robustness of the SAP adapter no matter whether it be the dot net connector version or the WCF version.

BizTalk Server 2006 R2 Exam

BizTalk Server 2006 R2 Exam

I like to wish you all a happy new year to start with. Before end of 2009 I passed the 70-241 BizTalk exam. This exam has been around for quite a while and I kept postponing to take it for a long time, but I finally decided to take it. So now my logo looks like this (maybe not exciting and many of you may have similar logo’s but still I am proud to have achieved this):

MCTS(rgb)_1268_511 

As soon as there will be an exam for BizTalk 2009 I will take sooner and not wait for ever :).