セルフホステッド WCF 4.5 サービスから JSON を取得するにはどうすればよいですか?
Fiddler2 を使用して「Content-Type: application/json」(「Content-Type: application/javascript」も試しました) でリクエストを送信していますが、XML を取得し続けています。
WebHttpBehavior で「AutomaticFormatSelectionEnabled = true」を設定することと組み合わせて、XML を取得し、「Content-Type: application/json」を使用すると、サーバーがまったく応答しません (その後、エラー 103 が発生します)。
WebHttpBinding で CrossDomainScriptAccessEnabled を有効にし、コンソール ホストで WebServiceHost を使用しています。
サービスはとてもシンプルです:
[ServiceContract]
public interface IWebApp
{
[OperationContract, WebGet(UriTemplate = "/notes/{id}")]
Note GetNoteById(string id);
}
また、AutomaticFormatSelectionEnabled を false に設定し、サービス コントラクトで ResponseFormat = WebMessageFormat.Json を使用しようとしましたが、「エラー 103」が発生し、それ以上の情報はありません。
customErrors をオフにして、FaultExceptionEnabled、HelpEnabled を true に設定しました (これで何かができるかどうかはわかりませんが、すべて試してみたことを確認するためだけです)。
私はdllか何かを見逃していますか?