我有一个非常基本的WCF服务,我想在IIS上作为一个RESTful服务运行。这是服务合同。
[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);
}有一个名为StopMotion.Business.WCFService.RestCameraWs的类实现了这个约定。然后,我在我的web项目中添加了一个带有以下标记的.svc文件。
<%@ ServiceHost Service="StopMotion.Business.WCFService.RestCameraWsBase"%>当我导航到这个服务url时,它显示了服务主页和一个指向wsdl定义的链接。但是当我在我的web.config文件中添加配置来在webHttpBinding上配置这个服务时,我从IIS express得到以下错误页面。

首先,我认为我在配置方面做错了什么。后来我删除了配置,只是在svc文件中更改了工厂,如下所示
<%@ ServiceHost Factory="System.ServiceModel.Activation.WebServiceHostFactory" Service="StopMotion.Business.WCFService.RestCameraWsBase"%>据说WebServiceHostFactory默认使用webHttpBinding,我们不需要在配置中添加它,除非我们需要更多的东西。但是更改工厂也会在IIS Express上导致相同的错误页面。
知道这是怎么回事吗?
发布于 2012-04-13 15:39:53
查看我的配置,我记得我必须在行为中的web.config和enableWebScript中声明端点。部分结果看起来有点像:
    <endpoint address="json" binding="webHttpBinding" contract="svcservice.svc.IAuthsvc" bindingConfiguration="bc.svcservice.svc.AuthsvcJSON" behaviorConfiguration="epb.svcservice.svc.AuthsvcJSON"/>      
    .
    .
    .
    .
    <behavior name="epb.svcservice.svc.AuthsvcJSON">
      <enableWebScript/>
    </behavior>希望这能对你有所帮助
https://stackoverflow.com/questions/10136739
复制相似问题