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

  • Home
  • SEARCH
  • 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 7402201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:40:58+00:00 2026-05-29T04:40:58+00:00

I have developed a sample WCF REST service that accepts that creates an Order

  • 0

I have developed a sample WCF REST service that accepts that creates an “Order” object, the method implementation is as shown below:

[Description("Updates an existing order")]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, UriTemplate = "/Orders")]
[OperationContract]
public void UpdateOrder(Order order)
    {
        try
        {
            using (var context = new ProductsDBEntities())
            {
                context.Orders.Attach(order);
                context.ObjectStateManager.ChangeObjectState(order, System.Data.EntityState.Modified);
                context.SaveChanges();
                WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.OK;
                WebOperationContext.Current.OutgoingResponse.StatusDescription = "Order updated successfully.";
            }
        }
        catch (Exception ex)
        {
            WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.InternalServerError;
            WebOperationContext.Current.OutgoingResponse.StatusDescription = ex.Message + " " + ((ex.InnerException != null) ? ex.InnerException.Message : string.Empty);
        }
    }

I am trying to consume this service in a client using the “WCF Rest Starter Kit” assemblies. The client side code to consume the service is as below:

var order = new Order(){
              OrderId = Convert.ToInt32(ddlCategories.SelectedItem.Value)
};

order.Order_X_Products.Add(new Order_X_Products { ProductId = 1, Quantity = 10});
order.Order_X_Products.Add(new Order_X_Products { ProductId = 2, Quantity = 10});
var content = HttpContentExtensions.CreateJsonDataContract<Order>(order);
var updateResponse = client.Post("Orders", content);

The below line

var updateResponse = client.Post("Orders", content);

throws the following error:

Server Error in '/' Application.

Specified argument was out of the range of valid values.
Parameter name: value

Description: An unhandled exception occurred during the execution of the current web    request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: value

I have a similar logic to create an order and its working fine.

I also tried by removing the following lines

order.Order_X_Products.Add(new Order_X_Products { ProductId = 1, Quantity = 10});
order.Order_X_Products.Add(new Order_X_Products { ProductId = 2, Quantity = 10});

but still the same error.

Please help me solve this issue.

I have also tried serializing the Order object to XML and changing the RequestFormat of UpdateOrder method to XML. In this case I am getting the following error, if any related entities are populated.

Server Error in '/' Application.

Object graph for type 'WcfRestSample.Models.Common.Order_X_Products' contains cycles and  cannot be serialized if reference tracking is disabled.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Runtime.Serialization.SerializationException: Object graph for type 'WcfRestSample.Models.Common.Order_X_Products' contains cycles and cannot be serialized if reference tracking is disabled.

Source Error: 


Line 102:
Line 103: var content = HttpContentExtensions.CreateDataContract<Order>  (order);
Line 104: var updateResponse = client.Post("Orders", content);
Line 105:
Line 106:

I want to “Update” an order along with the related “Products” through the “Order_X_Products” mapping table.

  • 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-29T04:40:59+00:00Added an answer on May 29, 2026 at 4:40 am

    There is a post here http://smehrozalam.wordpress.com/2010/10/26/datacontractserializer-working-with-class-inheritence-and-circular-references/ that talks about how to deal with circular references when using the DataContractSerializer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple windows Service that is developed in vb.net 2008. When
I have developed a WCF Service Application hosted in IIS 7.5 targeting .NET 3.5
I have developed an Android activity that pushes NDEF message like in android sample
I have developed one REST WCF and would like to client will use it
I have a simple windows Service developed in VS.net 2008 and VB.net. When I
I have a simple web service that has an API third party developers are
I have developed a small iPhone application by using singleton that I use to
I have developed one WCF application, and it is working as a middle layer
I have a simple windows service, that might need to be configured on-the-fly (a
I have developed a sample in latest PHP 5.3 and have realized it later

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.