Wednesday 30 March 2011

Endpoints using 'UriTemplate' cannot be used with 'System.ServiceModel.Description.WebScriptEnablingBehavior'.

I was getting this exception (Endpoints using 'UriTemplate' cannot be used with 'System.ServiceModel.Description.WebScriptEnablingBehavior'.) all the time, after I specified my service contract (I was using WebScriptEnablingBehavior):
public interface ICourseService
{
 [WebGet(UriTemplate = "GetCourseList", ResponseFormat = WebMessageFormat.Json)]
 [OperationContract]
 List GetCourseList();
}
Well... it turns out, this parameter combination is forbidden, instead use this:
public interface ICourseService
{
 [WebGet(ResponseFormat = WebMessageFormat.Json)]
 [OperationContract]
 List GetCourseList();
}
notice, there's no UriTemplate. Eventhough you can still navigate to: http://localhost:60377/TestSite/test.svc/GetMyList and it will retrieve JSON file.

No comments:

Post a Comment