ServicesResourcesConferencesOur TeamWeblogsAboutContact
   

Subscriptions

Post Categories

News

    MicrosoftBizTalkBlogs

Affiliations

Archives

Self-Hosting Your ADO.NET Data Services ("Astoria") Services

The official ADO.NET Data Services (hm, am I the only who thinks that this - again - is not a perfect name...?) documentation doesn't alk about and doesn't show how to self-host your Astoria services - the samples and quickstarts always use ASP.NET/IIS to expose the WCF-based services that Astoria is using.

By looking a bit around in Reflector I managed to create a self-hosted Astoria service which (for this example) is hosted in a Console application.

We have several steps to fulfill our task:
  • Create the ADO.NET Entity Model
  • Implement your Astoria Service
  • Configure endpoint(s)
  • Create a ServiceHost instance
Creating the Entity Data Model is no special thing as well as implementing an Astoria service. Just follow the offical steps for the respective topic in the ADO.NET Data Services Quickstart docs.

Astoria uses one generic universal contract for implementing the service base class. The service class you already built above is a derivate of WebDataService<T> and the WCF universal ServiceContract is Microsoft.Data.Web.IRequestHandler which can be found in the Microsoft.Data.Web assembly.

[ServiceContract]
public interface IRequestHandler
{
  [OperationContract]
  [WebInvoke(UriTemplate="*", Method="*")]
  Message ProcessRequestForMessage(Stream messageBody);
}

So everything we need to do now is to create an endpoint definition which uses these artifacts and leverages the webHttpBinding which was introduced in .NET 3.5

<system.serviceModel>
  <services>
    <service name="SelfHostedAstoria.WebDataService">       
      <endpoint
        address="http://localhost:7777/Services/Data/NW"
        binding="webHttpBinding"
        behaviorConfiguration="webHttp"
        contract="Microsoft.Data.Web.IRequestHandler" />
    </service>
  </services>
</system.serviceModel>

In order to actually expose our Astoria Service we need to hook up a ServiceHost instance. In our case we will use the WebServiceHost (living in System.ServiceModel.Web) which already takes care about setting up the needed behavior on all webHttpBinding-based endpoints.

WebServiceHost host = new WebServiceHost(typeof(WebDataService));
host.Open();
...


Easy! Now we have a self-hosted Astoria service.

Self-hosted ADO.NET Dat Services ('Astoria') Service


posted on Tuesday, December 11, 2007 12:24 PM

# Link Listing - December 11, 2007 @ Wednesday, December 12, 2007 7:29 AM

Link Listing - December 11, 2007
Christopher Steen

# New and Notable 210 @ Wednesday, December 12, 2007 3:01 PM

Prodded by Mike to pick up the slack, I am trying to get one of these out each morning before all my
Sam Gentile

# How to self host Astoria (Ado.net Data Services) @ Wednesday, December 12, 2007 11:45 PM

You've been kicked (a good thing) - Trackback from DotNetKicks.com
DotNetKicks.com

# Downloaded ADO.NET Data Services @ Thursday, December 13, 2007 8:50 PM

...and followed Christian's great advice over here to get myself hosted inside of a console application;...
Mike Taulty's Blog

# ADO.NET Data Service をローカルマシンで実行する @ Friday, December 14, 2007 4:03 AM

Self-Hosting Your ADO.NET Data Services (&amp;quot;Astoria&amp;quot;) Services ADO.NET Data Service は以前Astoriaとよばれていた、データベースを簡単にクラウドの向こう側に持っていくための技術です(と私は思っています)。...
どっとねっとふぁんBlog

# ADO.NET Data Services - Getting Started (2) @ Wednesday, December 19, 2007 2:26 PM

The bits for ADO.NET Data Services (&quot;Astoria&quot;) primarily seem to live in an assembly Microsoft.Web.Data.dll...
Mike Taulty's Blog

# Seriously good content on creating and using data services @ Friday, December 21, 2007 10:37 PM

There is a number of folks that have been writing about Astoria. Collectively they built a lot of reference
Noticias externas

# Fast, simple test app for ADO.NET Data Services @ Thursday, January 03, 2008 12:30 AM

If you're currently looking at the ADO.NET Data Services functionality that is available through the
Marcelo's WebLog

# Fast, simple test app for ADO.NET Data Services @ Thursday, January 03, 2008 12:37 AM

If you&amp;#39;re currently looking at the ADO.NET Data Services functionality that is available through
Noticias externas

# ADO.NET Data Services 的Self-Hosting实例 @ Sunday, January 13, 2008 9:26 AM

Fast, simple test app for ADO.NET Data Services http://blogs.msdn.com/marcelolr/archive/2008/01/02/fast-simple-test-app-for-ado-net-data-services.aspx
ccBoy's WebLog

# Lexapro zoloft wellbutrin. @ Saturday, July 19, 2008 3:58 AM

Lexapro. Lexapro prescribe day.
Lexapro.


Powered by Community Server, by Telligent Systems