組み込みのMicrosoftは親子関係からのサイクルをサポートしていないため、このガイドに従ってカスタムフォーマッターを作成し、オブジェクトのシリアル化にNewtonsoftJson.NETを使用できるようにしました。
http://blogs.msdn.com/b/carlosfigueira/archive/2011/05/03/wcf-extensibility-message-formatters.aspx
彼の例では、ServiceHostを手動で作成しています。このガイドで教えてくれたRoutesとWebServiceFactoryを活用しています。
http://blogs.msdn.com/b/endpoint/archive/2010/01/06/introducing-wcf-webhttp-services-in-net-4.aspx
私が言えることから、サービスエンドポイントに適切な動作を追加する方法を理解する必要があります。私を正しい方向に向ける手助けをいただければ幸いです。
参照しやすいように、以下のいくつかのコードスニペット...
私のGlobal.asaxで
WebServiceHostFactory webServiceHostFactory = new WebServiceHostFactory();
RouteTable.Routes.Add(new ServiceRoute(Accounts.Route, webServiceHostFactory, typeof(Accounts)));
私のweb.configの場合
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<standardEndpoints>
<webHttpEndpoint>
<!--
Configure the WCF REST service base address via the global.asax.cs file and the default endpoint
via the attributes on the <standardEndpoint> element below
-->
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="false" defaultOutgoingResponseFormat="Json"/>
</webHttpEndpoint>
</standardEndpoints>
彼のプログラムの主な機能で
string baseAddress = "http://" + Environment.MachineName + ":8000/Service";
ServiceHost host = new ServiceHost(typeof(Service), new Uri(baseAddress));
host.AddServiceEndpoint(typeof(ITestService), new BasicHttpBinding(), "soap");
WebHttpBinding webBinding = new WebHttpBinding();
webBinding.ContentTypeMapper = new MyRawMapper();
host.AddServiceEndpoint(typeof(ITestService), webBinding, "json").Behaviors.Add(new NewtonsoftJsonBehavior());