Self Hosted WCF Rest service ERROR: Type "Newtonsoft.Json.Linq.JToken" is a recursive collection data contract that is not supported

I have a WCF Rest service that is self hosted. It works great until I figured I should use the JToken ( Newtonsoft.Json.Linq.JToken ). I got the error:

Type 'Newtonsoft.Json.Linq.JToken' is a recursive collection data contract which is not supported. Consider modifying the definition of collection 'Newtonsoft.Json.Linq.JToken' to remove references to itself.

      

I have seen all the answers from this post , this one and others. The point is that I accept my services in an internal program (in the company where I work, I cannot show it :-(). I do it exactly the same as myself, but the implementations and interfaces of my services are not a library of services WCF, but only a class library, so I cannot access the menu they talk about in the answers (where is: "Reusable types in specified referenced assemblies").

I couldn't find a solution and I would like to use JToken.

Here's my service contract:

[ServiceContract]
    public interface ISearchService
    {
        [OperationContract]
        [WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json,
            UriTemplate = "search/")]
        List<Client> SearchClient(JToken jsonBody);
    }

      

My hosting is done like in this post: How do I create WCF EndPointBehaviors in code and not setup? (I had to do this without a config file).

Hope my question is clear. Thank you for your help.

+3
rest json.net wcf self-hosting


source to share


No one has answered this question yet

See similar questions:

21
How do I create WCF EndPointBehaviors in code and not in configuration?
15
Error adding service reference: Type is a recursive contract with collection data not supported
ten
Replace WCF default JSON serialization
7
replace WCF inline JavascriptSerializer with Newtonsoft Json.Net json serializer
five
Retrieving "Recursive Collection Data Contract" when referencing a WCF service with a slightly complex method
1
How to parse a collection of unknown JSON object types inside a known JSON structure using JSON.Net?

or similar:

3
Self-service WCF with MEF and NetTcpBinding for push and pull mechanism
2
Authentication on WCF-Rest self-service service
2
405 status code for calling support from jQuery
1
Exception in native host wcf service - Type initializer for "System.ServiceModel.Diagnostics.TraceUtility" threw an exception
1
WCF Exception returns empty JQuery error in google chrome browser
1
I am creating a WCF web service and I am stuck with Post & Put methods where Get works fine. I got .edmx in it. Any solution?
0
DotNetOpenAuth and ResourceServer https configuration
0
Multiple WCF services for the same service and contract type
0
REST Web android client
0
Return JSON from self contained WCF 4.5 service?



All Articles
Loading...
X
Show
Funny
Dev
Pics