Volevo provare l'esempio this di un servizio Web ospitato autonomamente (originariamente scritto in WCF WebApi), ma utilizzando la nuova Web API ASP.NET (che è il discendente di WCF WebApi).Qual è l'equivalente di HttpServiceHost in Web App di ASP.NET?
using System;
using System.Net.Http;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using Microsoft.ApplicationServer.Http;
namespace SampleApi {
class Program {
static void Main(string[] args) {
var host = new HttpServiceHost(typeof (ApiService), "http://localhost:9000");
host.Open();
Console.WriteLine("Browse to http://localhost:9000");
Console.Read();
}
}
[ServiceContract]
public class ApiService {
[WebGet(UriTemplate = "")]
public HttpResponseMessage GetHome() {
return new HttpResponseMessage() {
Content = new StringContent("Welcome Home", Encoding.UTF8, "text/plain")
};
}
}
}
Tuttavia, o non ho NuGotten il pacchetto giusto, o HttpServiceHost è assente ingiustificato. (Ho scelto la variante "self hosting").
Cosa mi manca?
[This] (http://code.msdn.microsoft.com/ASPNET-Web-API-Self-Host-30abca12/view/Reviews) mi ha aiutato a far funzionare qualcosa, ma non sembra un equivalente rigoroso. – Benjol