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
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.
Houses are quite expensive and not everybody can buy it. However, credit loans was invented to aid people in such situations.
Posted by: LindsayDuffy | 05/07/2010 at 06:54 PM
*Every great achievement was a dream before it become a reality.
Posted by: christian louboutin shoes | 11/11/2010 at 09:12 AM
I did not discuss that particular issue!!
Posted by: moncler jackets | 11/16/2010 at 02:54 AM
I like your concept.*_*
Posted by: nike air max | 11/17/2010 at 09:09 AM
You can share some of your article, I'm like you write something, really very good! I will continue to focus on
Posted by: Air Yeezys | 04/12/2011 at 10:54 AM
I've been reading your post and I think have very good information, I would like to know the methodology you use to write your post.
Posted by: Inversiones en oro | 04/12/2011 at 05:23 PM