Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
C# / VB.NET - WCF e DataSet
Forum - C# / VB.NET - WCF e DataSet

Avatar
lorenzo (Normal User)
Guru


Messaggi: 1178
Iscritto: 15/04/2008

Segnala al moderatore
Postato alle 22:30
Sabato, 05/11/2011
Ragazzi, tra poco butto dalla finestra pc e .NET :d

In ufficio ho un servizio WCF(che ho fatto io e del quale possiedo quindi il codice) che espone alcuni metodi. Questi ricevono in ingresso un DataSet composto da alcuni DataTable.

Quando il dataset è piccolo(mooolto piccolo, nell'ordine di una tabella con 10 campi e 10 righe) tutto va bene. In qualsiasi altro caso più grande mi viene restituito errore di Bad Request (400). Il mio obbiettivo è di trasferire un dataset con una tabella di almeno 1000 colonne e 150000 righe.

Ho replicato una situazione identica sul mio PC a casa e mi da lo stesso errore.
L'app.config del client è il seguente:

CLIENT
Codice sorgente - presumibilmente Plain Text

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <configuration>
  3.   <system.serviceModel>
  4.     <bindings>
  5.       <wsHttpBinding>
  6.         <binding name="WSHttpBinding_IService1" closeTimeout="00:01:00"
  7.           openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
  8.           bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
  9.           maxBufferPoolSize="524288" maxReceivedMessageSize="100000000" messageEncoding="Text"
  10.           textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
  11.           <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
  12.             maxBytesPerRead="4096" maxNameTableCharCount="16384" />
  13.           <reliableSession ordered="true" inactivityTimeout="00:10:00"
  14.             enabled="false" />
  15.           <security mode="Message">
  16.             <transport clientCredentialType="Windows" proxyCredentialType="None"
  17.               realm="" />
  18.             <message clientCredentialType="Windows" negotiateServiceCredential="true"
  19.               algorithmSuite="Default" />
  20.           </security>
  21.         </binding>
  22.       </wsHttpBinding>
  23.     </bindings>
  24.     <client>
  25.       <endpoint address="http://localhost:51241/Service1.svc" binding="wsHttpBinding"
  26.         bindingConfiguration="WSHttpBinding_IService1" contract="ServiceReference1.IService1"
  27.         name="WSHttpBinding_IService1">
  28.         <identity>
  29.           <dns value="localhost" />
  30.         </identity>
  31.       </endpoint>
  32.     </client>
  33.   </system.serviceModel>
  34. </configuration>



il web.config del servizio è il seguente

SERVER
Codice sorgente - presumibilmente Plain Text

  1. <?xml version="1.0"?>
  2. <configuration>
  3.  
  4.   <configSections>
  5.     <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
  6.       <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
  7.         <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
  8.         <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
  9.           <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
  10.           <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
  11.           <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
  12.           <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
  13.         </sectionGroup>
  14.       </sectionGroup>
  15.     </sectionGroup>
  16.   </configSections>
  17.   <appSettings/>
  18.   <connectionStrings/>
  19.   <system.web>
  20.     <compilation debug="true">
  21.       <assemblies>
  22.         <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
  23.         <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
  24.         <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
  25.         <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
  26.       </assemblies>
  27.     </compilation>
  28.     <!--
  29.         The <authentication> section enables configuration
  30.         of the security authentication mode used by
  31.         ASP.NET to identify an incoming user.
  32.     -->
  33.     <authentication mode="Windows" />
  34.     <!--
  35.         The <customErrors> section enables configuration
  36.         of what to do if/when an unhandled error occurs
  37.         during the execution of a request. Specifically,
  38.         it enables developers to configure html error pages
  39.         to be displayed in place of a error stack trace.
  40.  
  41.         <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
  42.          <error statusCode="403" redirect="NoAccess.htm" />
  43.          <error statusCode="404" redirect="FileNotFound.htm" />
  44.         </customErrors>
  45.     -->
  46.     <pages>
  47.       <controls>
  48.         <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
  49.         <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
  50.       </controls>
  51.     </pages>
  52.  
  53.     <httpHandlers>
  54.       <remove verb="*" path="*.asmx"/>
  55.       <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
  56.       <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
  57.       <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
  58.     </httpHandlers>
  59.     <httpModules>
  60.       <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
  61.     </httpModules>
  62.   </system.web>
  63.   <system.codedom>
  64.     <compilers>
  65.       <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4"
  66.                 type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
  67.         <providerOption name="CompilerVersion" value="v3.5"/>
  68.         <providerOption name="WarnAsError" value="false"/>
  69.       </compiler>
  70.     </compilers>
  71.   </system.codedom>
  72.   <!--
  73.       The system.webServer section is required for running ASP.NET AJAX under Internet
  74.       Information Services 7.0.  It is not necessary for previous version of IIS.
  75.   -->
  76.   <system.webServer>
  77.     <validation validateIntegratedModeConfiguration="false"/>
  78.     <modules>
  79.       <remove name="ScriptModule" />
  80.       <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
  81.     </modules>
  82.     <handlers>
  83.       <remove name="WebServiceHandlerFactory-Integrated"/>
  84.       <remove name="ScriptHandlerFactory" />
  85.       <remove name="ScriptHandlerFactoryAppServices" />
  86.       <remove name="ScriptResource" />
  87.       <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode"
  88.            type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
  89.       <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode"
  90.            type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
  91.       <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
  92.     </handlers>
  93.   </system.webServer>
  94.   <runtime>
  95.     <assemblyBinding appliesTo="v2.0.05727" xmlns="urn:schemas-microsoft-com:asm.v1">
  96.       <dependentAssembly>
  97.         <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
  98.         <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
  99.       </dependentAssembly>
  100.       <dependentAssembly>
  101.         <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
  102.         <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
  103.       </dependentAssembly>
  104.     </assemblyBinding>
  105.   </runtime>  
  106.   <system.serviceModel>
  107.     <bindings>
  108.       <wsHttpBinding>
  109.         <binding name="binding1" maxReceivedMessageSize="100000000">
  110.         </binding>
  111.       </wsHttpBinding>
  112.   </bindings>
  113.     <services>
  114.       <service name="WcfService1.Service1" behaviorConfiguration="WcfService1.Service1Behavior">
  115.         <!-- Service Endpoints -->
  116.         <endpoint address="" binding="wsHttpBinding" contract="WcfService1.IService1">
  117.           <!--
  118.               Upon deployment, the following identity element should be removed or replaced to reflect the
  119.               identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity
  120.               automatically.
  121.           -->
  122.           <identity>
  123.             <dns value="localhost"/>
  124.           </identity>
  125.         </endpoint>
  126.         <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  127.       </service>
  128.     </services>
  129.     <behaviors>
  130.       <serviceBehaviors>
  131.         <behavior name="WcfService1.Service1Behavior">
  132.           <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
  133.           <serviceMetadata httpGetEnabled="true"/>
  134.           <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
  135.           <serviceDebug includeExceptionDetailInFaults="true"/>
  136.         </behavior>
  137.       </serviceBehaviors>
  138.     </behaviors>
  139.   </system.serviceModel>
  140.  
  141. </configuration>



Ho provato a:

1) aumentare la proprietà maxReceivedMessageSize(sul server e sul client)
2) usare Binary encoding invece che Text encoding


Avete soluzioni?

PM
Avatar
HeDo (Founder Member)
Guru^2


Messaggi: 2765
Iscritto: 21/09/2007

Up
2
Down
V
Segnala al moderatore
Postato alle 1:29
Domenica, 06/11/2011

come prima cosa mi viene da chiederti che necessità c'è di trasferire così tanti dati  in una volta, puoi servirti del paging per ottimizzare la quantità di informazioni scambiate in rete.

seconda cosa, assicurati di trasferire i dati in json in quanto è un formato più compatto e leggero dell'xml.

infine se leggi qui c'è una soluzione: http://stackoverflow.com/questions/884235/wcf-how-to-incre ...

Devo trasferire tutti quei dati per un semplice motivo: sto lavorando con un database realtime, che possiede però un sql engine incredibilmente lento. Mi stato detto(dall'azienda produttrice) di usare delle API di basso livello che però possono lavorare solo lato server. - lorenzo - 06/11/11 09:48
Essende API a basso livello, non permettono filtri SQL ma solo richieste molto generiche.Sono API davvero rapide, quindi l'idea è di chiedere una tabella intera(o più tabelle) per poi filtrare i dati lato codice. Per questo uso un DataSet. - lorenzo - 06/11/11 09:50
questo che hai detto è l'antitesi di un accesso veloce ai dati. - HeDo - 06/11/11 10:21
non ci posso fare nulla, se il prodotto è così. Devo trovare un modo per farlo e se hai qualche altra idea la ascolto molto volentieri. Comunque, la stessa documentazione delle api segnala di usarle in questo modo, anche perché espongono solo un iteratore per ciclare su tutta la tabella, nient'altro - lorenzo - 06/11/11 14:33
PM