잘 작동하는 WCF REST 템플릿 40 (CS)을 사용하여 간단한 REST 서비스를 만들었습니다. 응답에서 "application/json"을 콘텐츠 유형으로 사용하지만 "text/plain"이 필요하다는 문제 만 있습니다.WCF REST WebService 콘텐츠 형식이 잘못되었습니다.
문제는 이미 블로그 게시물에 설명되어 있지만 템플릿 때문에 .svc 파일을 사용하고 있지 않습니다. 그래서 제안 된 솔루션은 나를 위해 작동하지 않습니다.
내 서비스 계약 :[ServiceContract]
public interface ICouchService
{
[OperationContract]
[WebInvoke(ResponseFormat = WebMessageFormat.Json, UriTemplate = "/", Method = "GET")]
ServiceInformation Hello();
[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Json, UriTemplate = "/piclib/{id}")]
CouchDocument GetDocument(string id);
}
의 Web.config : 당신은 WCF REST 서비스에서 임의의 내용을 반환하려는 경우, 당신은 원시 프로그래밍 모델을 사용할 필요가
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</modules>
</system.webServer>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="false"/>
</webHttpEndpoint>
</standardEndpoints>
</system.serviceModel>