Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to reference a WCF Web Service via URI/ how to POST to WCF Service via URI?
    primarykey
    data
    text
    <p>I am new to creating Web Services and I do not understand exactly how to access my web service. </p> <p>What I am trying to do is the create a WCF webservice that reads JSON data that is posted to it and deserializes it then does something. </p> <p>I have create a very simple WCF service with two methods exposed and a uri endpoint created. Though when I go to my uri I get nothing. </p> <p>I should be able to navigate to 'http:// localhost : 8000/asd/EchoWithGet?s=Hello, world!' in my browser and that method should return "You said " + s. When I navigate to that with the service running I get nothing. </p> <p>My question is how do I interface my program? Can I also post to my service via an HTML form then open a IO reader?</p> <p>Thanks in advance for the help.</p> <p>Below is my code. </p> <pre><code>namespace WcfService1 { [ServiceContract] public interface IService1 { [OperationContract] [WebGet] string EchoWithGet(string s); [OperationContract] [WebInvoke] string EchoWithPost(string s); } public class Service1 : IService1 { public string EchoWithGet(string s) { return "You said " + s; } public string EchoWithPost(string s) { return "You said " + s; } } class program { static void Main(string[] args) { WebServiceHost host = new WebServiceHost(typeof(Service1), new Uri("http://localhost:8000/asd/")); ServiceEndpoint ep = host.AddServiceEndpoint(typeof(IService1), new WebHttpBinding(), ""); /* ServiceDebugBehavior sdb = host.Description.Behaviors.Find&lt;ServiceDebugBehavior&gt;(); sdb.HttpHelpPageEnabled = false; */ host.Open(); Console.WriteLine("Service is running"); Console.WriteLine("Press enter to quit..."); Console.ReadLine(); host.Close(); } } </code></pre> <p>Thanks in advance for the help</p> <p>Updated, I think my issue stems from my config file. What information do I need to add to the config file to be able to consume my web service via the browser? </p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;configuration&gt; &lt;system.web&gt; &lt;compilation debug="true" targetFramework="4.0" /&gt; &lt;/system.web&gt; &lt;system.serviceModel&gt; &lt;behaviors&gt; &lt;serviceBehaviors&gt; &lt;behavior&gt; &lt;serviceMetadata httpGetEnabled="true"/&gt; &lt;serviceDebug includeExceptionDetailInFaults="false"/&gt; &lt;/behavior&gt; &lt;/serviceBehaviors&gt; &lt;/behaviors&gt; &lt;serviceHostingEnvironment multipleSiteBindingsEnabled="true" /&gt; &lt;/system.serviceModel&gt; &lt;system.webServer&gt; &lt;modules runAllManagedModulesForAllRequests="true"/&gt; &lt;/system.webServer&gt; &lt;/configuration&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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. 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