Problem receiving very large JSON in Restful Webservice

Asked

Viewed 727 times

0

We work here with Android + Webservice (.Net Restful) for data communication.

We are receiving the data in JSON format in a method, below:

//Método
public Retorno MetodoA(string sConexao, string sBanco, string sImeiDispositivo, List<Entidade> sJSON)

//Contrato
[OperationContract]
        [WebInvoke(UriTemplate = "/MetodoA/{sConexao}/{sBanco}/{sImeiDispositivo}",
            Method = "POST",
            BodyStyle = WebMessageBodyStyle.Bare,
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json)]
        Retorno MetodoA(string sConexao, string sBanco, string sImeiDispositivo, List<Entidade> sJSON);

Until now it was working normally, but we sent a very large JSON, and started to present an error that we could not find the solution yet.

I believe the problem is on the web.config, but I don’t know what exactly. I have in my Webservice a place where I am passing the maximum amount and Buffer for sending and receiving.

<system.serviceModel>
    <!-- AQUI -->
    <bindings>
      <!-- pick whichever binding you want .... -->
      <webHttpBinding>
        <!-- binding configuration with a name -->
        <binding name="ExtendedMaxSize" maxBufferSize="2000000" maxReceivedMessageSize="2000000"/>
      </webHttpBinding>
    </bindings>

This is the error that returns:

The server encountered an error while processing the request. See the server logs for more details

But this error only happens when JSON data is too large.

What can it be?

  • Putting this code below: <serviceDebug includeExceptionDetailInFaults="true"/> I could see that it was a field that was of a different type than received. I changed it and it worked. Thanks.

  • Rafael, you can answer your own question and mark as accepted.

1 answer

1

Putting this code down on my web.config, I could see that it was a field that was with different type than received. I changed it and it worked.

<serviceDebug includeExceptionDetailInFaults="true"/> 
  • Mark as correct!

  • I am waiting for the time the forum asks to make this appointment after that. Thank you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.