Следующее настроит эквивалент DataServiceHost
, прослушивая конечную точку uri
.
DataServiceHost CreateServiceHost(Uri uri)
{
var host = new DataServiceHost(typeof(FooDataService), new Uri[] { });
// these may need to be added if they don't already exist.
host.Description.Behaviors.Find<ServiceMetadataBehavior>().HttpGetEnabled = true;
host.Description.Behaviors.Find<ServiceDebugBehavior>().IncludeExceptionDetailInFaults = true;
host.AddServiceEndpoint(
new ServiceEndpoint(ContractDescription.GetContract(typeof(FooDataService)))
{
Name = "default",
Address = new EndpointAddress(uri),
Contract = ContractDescription.GetContract(typeof(IRequestHandler)),
Binding = new WebHttpBinding()
});
return host;
}