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ファイル:
<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>