2011-05-26 13 views
5

Tengo el servicio WCF mediante el cual estoy agregando datos en la base de datos. Funciona bien, pero cuando trato de enviar un byte grande [], devuelve "el servidor remoto devolvió un error: NotFound".Error al enviar una matriz de bytes grandes

web.config

<?xml version="1.0"?> 
<configuration> 
    <connectionStrings> 
    <add name="JabsBaseConnectionString" connectionString="Data Source=TAHASAGHIR-PC\SQLEXPRESS;Initial Catalog=JabsBase;Integrated Security=True" providerName="System.Data.SqlClient"/> 
    </connectionStrings> 
    <system.web> 
    <compilation debug="true" targetFramework="4.0"> 
     <assemblies> 
     <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> 
     </assemblies> 
    </compilation> 
    <httpRuntime maxRequestLength="2097151" useFullyQualifiedRedirectUrl="true"/> 
    </system.web> 
    <system.serviceModel>  
    <serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true" /> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="SendLargeChat" 
       allowCookies="false" 
       bypassProxyOnLocal="false" 
       maxBufferPoolSize="2147483647" 
       maxReceivedMessageSize="2147483647" 
       maxBufferSize="2147483647" 
       closeTimeout="10:00:00" 
       openTimeout="10:00:00" 
       receiveTimeout="10:00:00" 
       sendTimeout="10:00:00" 
       transferMode="Streamed"> 
      <readerQuotas 
      maxArrayLength="2147483647" 
      maxBytesPerRead="2147483647" 
      maxDepth="2147483647" 
      maxNameTableCharCount="2147483647" 
      maxStringContentLength="2147483647" /> 
     </binding> 
     </basicHttpBinding>  
    </bindings> 
    <services> 
     <service name="Prototype.SendChatService" behaviorConfiguration="Prototype.SendChatServiceBehavior"> 
     <endpoint address="" binding="basicHttpBinding" bindingConfiguration="SendLargeChat" contract="Prototype.SendChatService" /> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     </service>  
    </services>  
    <behaviors> 
     <serviceBehaviors> 
     <behavior name=""> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="true" /> 
     </behavior> 
     <behavior name="Prototype.SendChatServiceBehavior"> 
      <serviceMetadata httpGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 
</configuration> 

ServiceReferences.ClientConfig

<configuration> 
    <system.serviceModel> 
    <bindings> 
     <basicHttpBinding>   
     <binding name="BasicHttpBinding_ISendChatService" maxBufferSize="2147483647" 
      maxReceivedMessageSize="2147483647"> 
      <security mode="None" /> 
     </binding> 
     </basicHttpBinding>  
    </bindings> 
    <client>  
     <endpoint address="http://localhost:53756/PrototypeSite/SendChatService.svc" 
     binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISendChatService" 
     contract="SendChatService.ISendChatService" name="BasicHttpBinding_ISendChatService" /> 
    </client> 
    </system.serviceModel> 
</configuration> 

Solicitud POSTAL http://localhost:53756/PrototypeSite/SendChatService.svc HTTP/1.1 Host : localhost: 53756 conexion: keep-alive Referer: http://localhost:53756/PrototypeSite/ClientBin/Prototype.xap Longitud del contenido: 1348176 soapaction: "http://tempuri.org/ISendChatService/addMsg" content-type: text/xml; charset = utf-8 Accept: / User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/534.24 (KHTML, como Gecko) Chrome/11.0.696.68 Safari/534.24 Accept-Encoding: gzip, desinflar, SDCH Accept-Language: en-US, en; q = 0,8 Accept-Charset: ISO-8859-1, UTF-8; q = 0,7, *; q = 0,3

Respuesta HTTP/1.1 400 Bad Request Servidor: ASP.NET Development Server/10.0.0.0 Fecha: Jueves, 26 de mayo de 2011 17:48:00 GMT X-AspNet-Version: 4.0.30319 Cache-Control: private Content-Length: 0 Conexión: Cerrar

Respuesta

0

LO SENTIMOS, MI RESPUESTA ES INCORRECTA. IGNORE IT

Lo eliminaré en unas pocas horas, permitiendo que las personas con comentarios lo vean.

Haz no matrices de bytes de envío en SOAP.

Cada byte se transferirá como <byte>128</byte> o similar, lo que significa que tomará un promedio de 10 veces más.

Use base64 cadena en su lugar - así que defina su propiedad como una cadena y rellenela como cadena base64.

+0

Aliostad, gracias por su rápida respuesta! ¿Puede dar los detalles del proceso, cómo convertir la matriz de bytes a la cadena base64 y viceversa? – Taha

+0

wow. Eso es realmente algo útil para saber. ¿Tienes una referencia que explique esto? – Xhalent

+0

Eso no suena bien ... Estoy bastante seguro de que byte [] es codificado como una cadena Base64 por el serializador ... p. Ej. http://webservices20.blogspot.com/2010/10/important-wcf-performance-issue.html – TheNextman

1

creo que debe aplicar el mismo

<readerQuotas ... 

En el cliente.

2

El error 404/No encontrado es el error que Silverlight informa de todos los errores del servidor. Si desea saber el error real que se devuelve desde el servidor, puede usar algo como Fiddler para ver lo que se está enviando y recibiendo, incluidos los encabezados que contienen el código de error real y el mensaje de error devuelto por el servidor.

+0

Este es un buen consejo – TheNextman

+0

Gracias David ... ¡Estoy editando mi publicación original! Por favor, compruebe la solicitud y la respuesta. – Taha

+1

La mala solicitud puede ser una cantidad de cosas: el xml enviado está roto (puede verificarlo en Fiddler, ver si los datos de la solicitud se pueden ver como XML), el contrato utilizado por la solicitud no es el mismo que el servidor (improbable) si ha escrito ambos desde el mismo código WCF), o la solicitud infringe una verificación de rango. ¿La solicitud excede los 64 KB? Puede estar rompiendo el límite predeterminado MaxReceivedMessageSize establecido en su servicio WCF. – David

1

intenta agregar un entorno executionTimeout a su httpRuntime establecer

<httpRuntime executionTimeout="110" maxRequestLength="..." /> 
1

En mi experiencia, yo estaba recibiendo un error porque, aunque el servicio en el servidor se configura para recibir una gran cantidad de datos, el http tiempo de ejecución no era. Asegúrese de que su httpRuntime tenga un maxRequestLength apropiado.

1

También puede activar el registro de WCF para obtener más información. Agregue lo siguiente a su web.config:

<system.diagnostics> 
    <sources> 
     <source name="System.ServiceModel" 
        switchValue="Information, ActivityTracing" 
        propagateActivity="true"> 
      <listeners> 
       <add name="traceListener" 
        type="System.Diagnostics.XmlWriterTraceListener" 
        initializeData= "c:\log\Traces.svclog" /> 
      </listeners> 
     </source> 
    </sources> 
</system.diagnostics> 
Cuestiones relacionadas