I have a very basic WCF service that I want to run on IIS as a RESTful service. Here is the service contract.
[ServiceContract]
interface IRestCameraWs
{
[OperationContract]
[WebGet(UriTemplate = "/cameras/{username}",ResponseFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.Wrapped)]
CameraInfo[] GetUserCameras(string username);
[OperationContract]
[WebGet(UriTemplate = "/liveimage/{cameraId}",ResponseFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.Wrapped)]
byte[] GetLiveImage(int cameraId);
//void GetLatestImage(int cameraId, out DateTime timestamp, out byte[] image);
[OperationContract]
[WebGet(UriTemplate = "/latestimage/{cameraId}", ResponseFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.Wrapped)]
string GetLatestImageUrl(int cameraId);
}
There is a class which implements this contract called StopMotion.Business.WCFService.RestCameraWs
. Then I added an .svc
file in my web project with following markup.
<%@ ServiceHost Service="StopMotion.Business.WCFService.RestCameraWsBase"%>
When I navigate to this service url, it shows me service home page and a link to wsdl definition. But when I add configuration in my web.config
file to configure this service on webHttpBinding
I get following error page from IIS express.
First I thought I am doing something wrong with configuration. Later I deleted the configuration and just changed the factory in svc file like
<%@ ServiceHost Factory="System.ServiceModel.Activation.WebServiceHostFactory" Service="StopMotion.Business.WCFService.RestCameraWsBase"%>
WebServiceHostFactory
is said to use webHttpBinding
by default and we don't need to add this in configuration unless we need something more out of it. But changing factory also resulted in the same error page on IIS Express.
Any ideas what's going on here?