-1

I made a c# web services and in other hand i have a C# winform that consume that webservices, the problem is: the web services returns a DATASET with more of 5000 rows and a get a error

Error : The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.

Here is the code of the webservice:

[WebMethod]
    public DataSet cuentaAtrasadas()
    {
        SqlConnection myConnection = new SqlConnection("Data Source=192.168.87.15;" + "Initial Catalog=Indar;" + "User id=sa;" + "Password=;");

           DataSet ds = new DataSet();
           string query = "Select  Zona = Rama,  CxcInfo.Cliente,  Cte.Nombre,  Movimiento = CxcInfo.Mov,cxcinfo.estatus,  NumDoc = CxcInfo.MovID,  CxcInfo.Referencia,  Oc.MovId,  Comentarios = SubString(Cxc.Comentarios,1,50), " +
             "FechaEmision = Convert(Char(10), CxcInfo.FechaEmision, 103),  Vencimiento = Convert(Char(10), CxcInfo.Vencimiento, 103),  Dias = CxcInfo.DiasMoratorios,  Importe = (Cxc.Importe + Cxc.Impuestos),  Saldo = CxcInfo.Saldo, " +
             " FormaPago = Cte.Descripcion7,   cxc.comentariosCyc,   cxc.comentariosGte,   cxc.fechacomp,cxc.responsablecxc   FROM CxcInfo  Left Outer Join Cte On CxcInfo.Cliente=Cte.Cliente  Left Outer Join (Select Mov, MovId, EstatusOC, Docto, EstadoDocto " +
             " From ( Select E.Mov, E.MovId, EstatusOC = E.Estatus, E.FechaRegistro,         Docto = Em.Mov+' '+Em.MovId, EstadoDocto = Ed.Estado,       Rank() Over (Partition By Em.MovId Order By E.FechaRegistro Desc) As 'UltEmbF'     " +
            " From Embarque E         Left Outer Join EmbarqueD Ed ON E.ID = Ed.ID        Left Outer Join EmbarqueMov Em ON Ed.EmbarqueMov = Em.Id      Where E.Empresa = 'FIN'          And Em.Modulo = 'CXC'       And Em.Mov = 'Factura Indar' " +
            " And E.Mov = 'Orden Cobro'         ) Ue    Where UltEmbF = 1   ) Oc On Oc.Docto = CxcInfo.Mov+' '+CxcInfo.MovId , Cxc  WHERE Cxc.Cliente = Cte.cliente  And Cxc.Id = CxcInfo.Id  And CXCInfo.Empresa = 'FIN' " +
            " And (CxcInfo.Cliente Not In ('C000006') And CxcInfo.Cliente Not Like '[D,E,S,FSF,FIN]%')  And (CxcInfo.Saldo <> 0 And Cxc.Saldo <> 0)  and rama='Z130'  Order By CxcInfo.Mov";
        SqlDataAdapter da = new SqlDataAdapter(query, myConnection);
        da.SelectCommand.CommandTimeout = 0;
        da.Fill(ds, "CTE");
        return ds;
    }

and the code of the client:

 ServiceReference1.Service1SoapClient soap = new ServiceReference1.Service1SoapClient();

        DataSet ds = soap.cuentaAtrasadas();
        gridControl1.DataSource = ds.Tables[0].DefaultView;

And I get the error in this line: DataSet ds = soap.cuentaAtrasadas(); but where do i increase the MaxReceivedMessageSize property?

Filburt
  • 17,626
  • 12
  • 64
  • 115
wozzarvl
  • 304
  • 4
  • 17
  • Possible duplicate of http://stackoverflow.com/questions/14999779/maxreceivedmessagesize-and-maxbuffersize-in-app-config – Matteo Umili Sep 23 '15 at 15:11
  • 1
    1 - Delete all that and use Entity Framework. 2 - Delete all that and create a proper REST API Using ASP.Net Web API that allows you to query you data in a logical manner. Bringing up thousands of records that you're not going to use makes no sense at all. 3 - While you're at it, delete all that and use WPF. – Federico Berasategui Sep 23 '15 at 15:12

1 Answers1

1

I suggest you to set your values in the configuration file on your service in binding section :

<bindings>
      <basicHttpBinding>
        <binding name="Binding1"
                 maxReceivedMessageSize = "Your value">
          <security mode="None" />
        </binding>
      </basicHttpBinding>
    </bindings>

This sample is based on basicHttpBinding, you can have another bindings

Nate B.
  • 942
  • 11
  • 31
Aghilas Yakoub
  • 28,516
  • 5
  • 46
  • 51