Skip to content

Instantly share code, notes, and snippets.

@pmhsfelix
Created December 7, 2010 23:26
Show Gist options
  • Save pmhsfelix/732630 to your computer and use it in GitHub Desktop.
Save pmhsfelix/732630 to your computer and use it in GitHub Desktop.
Accessing the request input stream ...
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
namespace Drafts
{
[ServiceContract]
class TheService
{
[WebInvoke(UriTemplate = "*", Method = "POST")]
void HandlePost(Stream s)
{
Console.WriteLine("HandlePost");
Console.WriteLine(new StreamReader(s).ReadToEnd());
}
}
class Program
{
static void Main(string[] args)
{
using(var host = new WebServiceHost(typeof(TheService), new Uri("http://localhost:8080/base")))
{
host.AddServiceEndpoint(typeof (TheService), new WebHttpBinding(), "");
host.Open();
Console.WriteLine("Host is opened, press any key to continue");
Console.ReadKey();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment