Full source code for your reference is as below,
IService1.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
namespace WcfService3
{
[ServiceContract]
public interface IService1
{
[OperationContract]
[WebGet]
string GetDataUsingMethod(string value);
[OperationContract]
[WebGet(UriTemplate=“/GetData/{value}”)]
string GetDataUsingURI(string value);
}
}
Service1.svc.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
namespace WcfService3
{
public class Service1 : IService1
{
public string GetDataUsingMethod(string value)
{
return value + “I am returned by Method Name “;
}
public string GetDataUsingURI(string value)
{
return value + “I am returned by URI Name “;
}
}
}
Markup of Service1.svc
I hope this post was useful. Happy Coding
This is really a good video abt WCF Rest service.
Thnq
-Yuva
Why did you call it REST service?? you did not import WcfRestService1.dll to your project. Will it communicate with php or WorldPress services? W/o the proper implementation of REST service it will communicate with ASP.NET only.
Thx Steve
Hi Steve ,
It is REST Service because we are using webHttpBinding . and in this case webServiceHostFactory. and Yes THis can be consumed in PHP and JAVA Provided need to make HTTP call of this service
Dear Dhananjay
Watched your good video that is getting as simple approach as possible to implement web service
I just try to understand
According your last statement/answer to Steve – The definition of the REST Service is “Any Service (WCF?) that uses webHttpBinding ‘is’ the REST service” (More precise: The WCF service with REST protocol).
In this case may be your next video would be an evidence video that the project REST service consumes PHP and Java web services, but w/o adding WCFserviceREST Reference to your project! Another word: C:\dir WCFserviceREST.dll /s suppose to show file not found on your machine.
Thanks, Steve
This is awsome. realy a simple and easy to understand.how i can get more videos of similar..
Hi,
Very helpful video. I am new to REST WCF services. In this video I came across a sentence “We can not use other than string parameters in RESTful services” But http://msdn.microsoft.com/en-us/library/system.servicemodel.web.webservicehost.aspx link contains one example which has following method
[OperationContract]
[WebInvoke(UriTemplate = “add?x={x}&y={y}”)]
long Add(long x, long y);
Regards,
Hemant