2009-04-03 15 views
7

Tengo un servicio web simple para permitir que las aplicaciones consulten mi CMDB. La función con la que estoy teniendo problemas funciona con un pequeño conjunto de resultados pero falla con uno más grande, lo que indica que es algo en la configuración del servicio WCF que impide que tenga éxito.No se puede entender el mensaje de error de WCF, se necesita ayuda

Tengo una aplicación de prueba WinForms simple con una referencia de servicio para el servicio web y una sola función que llama a la función en cuestión.

El conjunto de resultados más pequeño arroja ~ 120KB de xml, el conjunto de resultados más grande que falla es ~ 2MB. Intenté aumentar el tamaño de maxReceivedMessageSize y maxStringContentLength sin éxito.

¿Hay alguna configuración que me he perdido? Esperaría un mensaje de error más detallado si ese era el problema.

Gracias de antemano,

Nick


El error del devuelto es:

System.ServiceModel.CommunicationException: The underlying connection was closed: The connection was closed unexpectedly. ---> 
System.Net.WebException: The underlying connection was closed: The connection was closed unexpectedly. 
    at System.Net.HttpWebRequest.GetResponse() 
    at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) 
    --- End of inner exception stack trace --- 

Server stack trace: 
    at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason) 
    at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) 
    at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) 
    at System.ServiceModel.Channels.ClientReliableChannelBinder`1.RequestClientReliableChannelBinder`1.OnRequest(TRequestChannel channel, Message message, TimeSpan timeout, MaskingMode maskingMode) 
    at System.ServiceModel.Channels.ClientReliableChannelBinder`1.Request(Message message, TimeSpan timeout, MaskingMode maskingMode) 
    at System.ServiceModel.Channels.ClientReliableChannelBinder`1.Request(Message message, TimeSpan timeout) 
    at System.ServiceModel.Security.SecuritySessionClientSettings`1.SecurityRequestSessionChannel.Request(Message message, TimeSpan timeout) 
    at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout) 
    at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) 
    at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs) 
    at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) 
    at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) 

Exception rethrown at [0]: 
    at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) 
    at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) 
    at TestRig.CmdbDataService.ICmdbDataService.GetMonitors(String client) 
    at TestRig.CmdbDataService.CmdbDataServiceClient.GetMonitors(String client) in C:\Documents and Settings\nfoster\My Documents\Visual Studio Projects\Virtual Operations Manuals\Trunk\src\TestRig\Service References\CmdbDataService\Reference.vb:line 1480 
    at TestRig.Form1.btnGetServers_Click(Object sender, EventArgs e) in C:\Apps\Virtual Operations Manuals\Trunk\src\TestRig\Form1.vb:line 8 

La función de llamada en la aplicación es:

Private Sub btnGetMonitors_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetMonitors.Click 
    txtResults.Text = String.Empty 
    Dim proxy As CmdbDataService.CmdbDataServiceClient = Nothing 
    Try 
    proxy = New CmdbDataService.CmdbDataServiceClient("WSHttpBinding_ICmdbDataService") 
    Dim monitors As TestRig.CmdbDataService.ConfigurationItems = proxy.GetMonitors(txtClientName.Text) 
    proxy.Close() 
    For Each monitor In monitors 
     txtResults.Text &= monitor.Name & " (" & monitor.TypeName & ")" & vbCrLf 
    Next 
    txtResults.Text &= monitors.Count & " monitors returned" 
    Catch ex As Exception 
    If Not IsNothing(proxy) AndAlso proxy.State <> ServiceModel.CommunicationState.Closed Then proxy.Abort() 
    txtResults.Text = ex.ToString 
    Finally 
    proxy = Nothing 
    End Try 
End Sub 

En La t lado plataforma est app.config contiene la siguiente ServiceModel:

<system.serviceModel> 
    <diagnostics> 
     <messageLogging logMalformedMessages="true" logMessagesAtServiceLevel="true" 
     logMessagesAtTransportLevel="true" /> 
    </diagnostics> 
    <behaviors /> 
    <bindings> 
     <wsHttpBinding> 
     <binding name="WSHttpBinding_Default" closeTimeout="00:05:00" 
      openTimeout="00:05:00" receiveTimeout="00:10:00" sendTimeout="00:05:00" 
      maxBufferPoolSize="104857600" maxReceivedMessageSize="104857600"> 
      <readerQuotas maxDepth="104857600" maxStringContentLength="104857600" 
      maxArrayLength="104857600" maxBytesPerRead="104857600" maxNameTableCharCount="104857600" /> 
     </binding> 
     </wsHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://localhost/CmdbServices/DataService.svc/soap12" 
     binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_Default" 
     contract="CmdbDataService.ICmdbDataService" name="WSHttpBinding_ICmdbDataService"> 
     <identity> 
      <userPrincipalName value="MyMachine\ASPNET" /> 
     </identity> 
     </endpoint> 
    </client> 
    </system.serviceModel> 

y en el lado del servicio es el web.config:

<system.serviceModel> 
    <diagnostics performanceCounters="Default"> 
     <messageLogging logMalformedMessages="true" logMessagesAtServiceLevel="true" 
     logMessagesAtTransportLevel="true" /> 
    </diagnostics> 
    <services> 
     <service behaviorConfiguration="ServiceBehavior" name="MyCorp.Cmdb.Services.DataService.CmdbDataService"> 
     <endpoint address="soap12" binding="wsHttpBinding" contract="MyCorp.Cmdb.Services.DataService.ICmdbDataService" /> 
     <endpoint address="soap11" binding="basicHttpBinding" contract="MyCorp.Cmdb.Services.DataService.ICmdbDataService" /> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="ServiceBehavior"> 
      <serviceMetadata httpGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 
+0

me gustaría tratar el aumento de los valores de tiempo de espera. –

Respuesta

15

Un colega mío acaba de señalarme en this blog post donde el verdadero culpable es la propiedad maxItemsInObjectGraph en los comportamientos del punto final.

Chocar estas arriba se ha resuelto el problema, hay que acaba de rebasar el umbral predeterminado de 65536: D

Es bueno ver los mensajes de error que apuntan en la dirección correcta :(

Saludos .. ..

también:. Usted puede obtener este error porque uno de sus métodos web están utilizando clase que no es una clase [DataContract]

+0

Archivo web de publicación de blog: http://web.archive.org/web/20071013175610/http://blogs.conchango.com:80/merrickchaffer/archive/2007/09/19/WCF-System.Net.WebException_3A00_-The-underlying-connection-was-closed_3A00_-The-connection-was-closed-unexpectedly.aspx –

0

ACTUALIZADO: OK, veo que ya se ha convertido en el rastreo . ¿Has mirado las huellas de WCF?

+0

He echado un vistazo a las huellas pero las encuentro realmente difíciles de descodificar, WCF no es mi área principal. La excepción se enumera allí, pero los detalles son exactamente los mismos que en la excepción original :( – Nick

0

intenta agregar esta captura en el código del lado del cliente:

catch (CommunicationException commProblem) 
{ 
    Console.WriteLine("There was a communication problem. " + commProblem.Message + commProblem.StackTrace); 
    Console.Read(); 

} 
Cuestiones relacionadas