Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7420063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:10:27+00:00 2026-05-29T08:10:27+00:00

I have written a WCF service with the REST template that has the defaultOutgoingResponseFormat

  • 0

I have written a WCF service with the REST template that has the defaultOutgoingResponseFormat set to Json. Under that, I have built a simple entity model using Entity Framework and ObjectContext, in order to pass around custom POCO entities.

If I pass a single entity, the system works as expected. If I add children to the entity, the REST response is blank. In the debugger, the entity is populated correctly, but the service itself returns nothing at all.

So, for instance, I have a Trip.Get() method. The WCF code looks like this:

[WebGet(UriTemplate = "{id}", ResponseFormat = WebMessageFormat.Json)]
public Model.Trip Get(string id)
{
    Model.Trip fetchedTrip = null;
    try
    {
        fetchedTrip = Library.Trip.Get(new Guid(id));
    }
    catch (Exception ex)
    {
        Debug.Write(ex.Message);
    }
    return fetchedTrip;
}

Library.Trip.Get looks like this in the working version:

public static Model.Trip Get(Guid tripId)
{
    using (Model.POCOTripContext context = new Model.POCOTripContext())
    {
        var tripEntity = context.Trips.FirstOrDefault(c => c.Id == tripId) ?? new Model.Trip();
        return tripEntity;
    }
}

This returns the expected result, which looks like this:

{“ArrivalDate”:”/Date(1334203200000-0400)/”,”DepartureDate”:”/Date(1334721600000-0400)/”,”Id”:”d6413d96-fe1f-4b1c-ae7a-3bbf516cdc2f”,”Name”:”Test 123″,”Photos”:null,”PlacesOfInterest”:null,”WhereTo”:”Orlando, FL”}

If I change the Library method to add in the children, however, the REST service returns a blank value. Nothing, nada.

public static Model.Trip Get(Guid tripId)
{
    using (Model.POCOTripContext context = new Model.POCOTripContext())
    {
        var tripEntity = context.Trips.Include("PlacesOfInterest").Include("Photos").Include("PlacesOfInterest.PoiAttributes").FirstOrDefault(c => c.Id == tripId) ?? new Model.Trip();
        return tripEntity;
    }
}

The debugger, in the WCF service on the return statement, shows that the entity is fully and correctly populated.

I am certain that I am just missing some magic attribute, and am hoping that someone who has dome this before might be able to help me out!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T08:10:28+00:00Added an answer on May 29, 2026 at 8:10 am

    According to your small test with removing back tracking navigation property you have problem with serialization to JSON. Default serialization is not able to track object references so when it starts serializing your Trip it follows navigation property to points of interest and in first of them it finds reference to Trip. Because it doesn’t track references it follows the navigation property and serializes trip again (and again follows his navigation properties) => infinite loop.

    You must either remove your back tracking navigation property as you did in test or you must tell serializer either to track references or to exclude that property from serialization (well I’m not sure what the first option will do in case of JSON). I guess you are using default WCF serialization so either:

    • Mark each entity with [DateContract(IsReference = true)] and each serialized property with [DataMember] attributes to start tracking references.
    • Or mark back tracking navigation property with [IgnoreDataMember] attribute to exclude the property from serialization
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a simple WCF service that accepts and stores messages. It works
I have written a very simple WCF service, that worked fine (code below), then
I have written a .NET Windows service which has a WCF service built into
i have written a stand alone WCF REST service in 4.0 under Studio 2010
I have written a service that I would like expose both via rest and
I have written a WCF service (I am a newb) that I want to
I've written a windows service application that exposes a WCF REST web service. The
I have a WCF Service that I have written, which is hosted within a
I have written a WCF service that I am hosting in IIS7 as a
I have a simple console app that calls a WCF service over net.tcp and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.