Send large JSON data to WCF Rest Service
- by Christo Fur
Hi
I have a client web page that is sending a large json object to a proxy service on the same domain as the web page.
The proxy (an ashx handler) then forwards the request to a WCF Rest Service. Using a WebClient object (standard .net object for making a http request)
The JSON successfully arrives at the proxy via a jQuery POST on the client webpage.
However, when the proxy forwards this to the WCF service I get a Bad Request - Error 400
This doesn't happen when the size of the json data is small
The WCF service contract looks like this
[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
[OperationContract]
CarConfiguration CreateConfiguration(CarConfiguration configuration);
And the DataContract like this
[DataContract(Namespace = "")]
public class CarConfiguration
{
[DataMember(Order = 1)]
public int CarConfigurationId { get; set; }
[DataMember(Order = 2)]
public int UserId { get; set; }
[DataMember(Order = 3)]
public string Model { get; set; }
[DataMember(Order = 4)]
public string Colour { get; set; }
[DataMember(Order = 5)]
public string Trim { get; set; }
[DataMember(Order = 6)]
public string ThumbnailByteData { get; set; }
[DataMember(Order = 6)]
public string Wheel { get; set; }
[DataMember(Order = 7)]
public DateTime Date { get; set; }
[DataMember(Order = 8)]
public List<string> Accessories { get; set; }
[DataMember(Order = 9)]
public string Vehicle { get; set; }
[DataMember(Order = 10)]
public Decimal Price { get; set; }
}
When the ThumbnailByteData field is small, all is OK. When it is large I get the 400 error
What are my options here?
I've tried increasing the MaxBytesRecived config setting but that is not enough
Any ideas?