tags:

views:

185

answers:

2
+1  Q: 

WCF and HTTP GET

My WCF service exposes this function

public SerialNumberInfo GetSerialNumberInfo(string serialNumber) { }

Is there a way to enable HTTP GET on my WCF service? Example:

http://localhost:8004/MyService/GetSerialNumberInfo?serialNumber=4
+1  A: 

yes, you need to use the webHttpBinding on your WCF service.

See the WCF REST Starter Kit for more information on REST Support in WCF.

If you're hosting your service in IIS, you need to create a separate *.svc file for the REST service (let's call it RESTService.svc), which contains:

<%@ ServiceHost Service="YourServiceName" Language="C#" debug="False"
    Factory="System.ServiceModel.Activation.WebServiceHostFactory" %>

Now you should be able to connect to the URL

http://localhost:8004/MyService/RESTService.svc

and get your data RESTfully.

Marc

marc_s
+1  A: 

What you want to do sounds like building a RESTful service with WCF. Check out the following article on MSDN, it has all the details:

A Guide to Designing and Building RESTful Web Services with WCF 3.5

0xA3