Hello coders,
In this article we are going to implement a RESTful service using WCF4.5.
Note: WCF stand for Windows Communication Foundation
Please follow the below steps to implement a RESTful service.
Step 1: Open visual studio/New project/WCF/WCF Service Application. See screen shot WcfService2.jpg.
Step 2: Add below line to your method as mine:-
> [WebInvoke(Method = "POST", UriTemplate = "/GetDataUsingDataContract", ResponseFormat= WebMessageFormat.Json, RequestFormat=WebMessageFormat.Json)]
> CompositeType GetDataUsingDataContract(CompositeType composite);
Step 3: Open your web.config file and set your service end point and ServiceBeharior as below:
<services>
<service name="WcfDemo.Service1" behaviorConfiguration="Service1Behavior">
<endpoint address="" binding="basicHttpBinding" contract="WcfDemo.IService1"></endpoint>
</service>
<behavior name="Service1Behavior">
<!-- To avoid disclosing metadata information, set the values below to false before deployment --><serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
These are the basic steps to implement RESTfull web service.
Happy coding.
1 Comment(s)