Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I made an end to end sample which runs in LINQPad. This is for a completely self-hosted scenario, and enables exploring various bindings, etc (for both the client and the server). Hope it's not over the top and posted the entire sample in case you find any of the other aspects helpful later on.</p> <pre><code> void Main() { MainService(); } // Client void MainClient() { ChannelFactory cf = new ChannelFactory(new WebHttpBinding(), "http://localhost:8000"); cf.Endpoint.Behaviors.Add(new WebHttpBehavior()); IService channel = cf.CreateChannel(); Console.WriteLine(channel.GetMessage("Get")); Console.WriteLine(channel.PostMessage("Post")); Console.Read(); } // Service void MainService() { WebServiceHost host = new WebServiceHost(typeof(Service), new Uri("http://localhost:8080")); ServiceEndpoint ep = host.AddServiceEndpoint(typeof(IService),new WebHttpBinding(), ""); ServiceDebugBehavior stp = host.Description.Behaviors.Find(); stp.HttpHelpPageEnabled = false; stp.IncludeExceptionDetailInFaults = true; host.Open(); Console.WriteLine("Service is up and running"); Console.ReadLine(); host.Close(); } // IService.cs [ServiceContract] public interface IService { [OperationContract] [WebInvoke(Method="GET", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)] string GetMessage(string inputMessage); [OperationContract] [WebInvoke(Method="POST", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)] string PostMessage(string inputMessage); [OperationContract] [WebInvoke(Method="POST", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)] System.IO.Stream PostJson(System.IO.Stream json); } // Service.cs public class Service : IService { public string GetMessage(string inputMessage){ Console.WriteLine(inputMessage); return "Calling Get for you " + inputMessage; } public string PostMessage(string inputMessage){ Console.WriteLine(inputMessage); return "Calling Post for you " + inputMessage; } public System.IO.Stream PostJson (System.IO.Stream json) { Console.WriteLine(new System.IO.StreamReader(json).ReadToEnd()); return json; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload