public static void Run() { using (var host = new HttpServiceHost(typeof(TheService), "http://localhost:8080/async")) { host.AddDefaultEndpoints(); var b = host.Description.Endpoints[0].Binding as HttpBinding; b.MaxBufferSize = 1*1024*1024; b.MaxReceivedMessageSize = 1*1024*1024; b.TransferMode = TransferMode.Streamed; host.Open(); Console.WriteLine("Host opened at {0}", host.Description.Endpoints[0].Address); Console.ReadKey(); } }
public void LoadStreamContentFromEmbeddedResource() { var content = new StreamContent(GetType().Assembly.GetManifestResourceStream(GetType(), "XForms.pdf")); //var content = new StringContent("Hwllo world"); var serviceUri = new Uri("http://localhost:1017/"); var config = new HttpConfiguration(); var host = new HttpServiceHost(typeof(TestService),config, new[] { serviceUri }); // Configure Endpoint for transferring large files host.AddDefaultEndpoints(); var endpoint = ((HttpEndpoint)host.Description.Endpoints[0]); endpoint.TransferMode = TransferMode.Streamed; endpoint.MaxReceivedMessageSize = 1024 * 1024 * 10; host.Open(); var httpClient = new HttpClient(); httpClient.BaseAddress = serviceUri; var response = httpClient.PostAsync("ResourceA",content).Result; Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); }