wcf complex-data-types

Tipos de datos complejos en WCF?



complex-data-types (14)

¿Especificaste en tu configuración de comportamiento del servicio? parece que falta información en esta stacktrace.

¿Puedes tomar la excepción en el lado del servidor (por ejemplo, en el modo de depuración de Visual Studio o con una biblioteca de registro como log4net).

¿Has intentado llamar a otros métodos (por ejemplo, helloworld () simple) en el mismo servicio para asegurarte de que la configuración del servicio en sí funciona? este tipo de exceptino también podría indicar algunos problemas de serialización. ¿Qué tipos quieres enviar por cable? usas KnownType en alguna parte?

Me he encontrado con un problema al tratar de devolver un objeto que contiene una colección de childobjects que de nuevo puede contener una colección de objetos nietos. Me sale un error, ''conexión cerrada por la fuerza por el host''.

¿Hay alguna manera de hacer funcionar esto? Actualmente tengo una estructura que se parece a esto:

pseudo código:

Person: IEnumerable<Order> Order: IEnumerable<OrderLine>

Los tres objetos tienen el atributo DataContract y todas las propiedades públicas que quiero exponer (incluidos los de IEnumerable) tienen el atributo DataMember.

Tengo varios OperationContract en mi servicio y todos los métodos que devuelven un solo objeto O un IEnumerable de un objeto funcionan perfectamente. Es solo cuando intento anidar IEnumerable que se vuelve malo. También en mi referencia de servicio al cliente elegí la lista genérica como mi tipo de colección. Solo quiero enfatizar que solo una de mis operaciones / métodos falla con este error, el resto funciona a la perfección .

EDITAR (descripción más detallada del error):

[SocketException (0x2746): An existing connection was forcibly closed by the remote host] [IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.] [WebException: The underlying connection was closed: An unexpected error occurred on a receive.] [CommunicationException: An error occurred while receiving the HTTP response to http://myservice.mydomain.dk/MyService.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.]

Intenté buscar registros pero no puedo encontrar ninguno ... también estoy usando un WSHttpBinding y un punto final http.


Agregue esta línea a <system.web/> :

<httpRuntime maxRequestLength="102400" executionTimeout="3600" />


Como nota, debe aprender a usar las utilidades de registro de WCF:

Información de registro.

Config Editor (facilita la configuración).

Visor de trazas Completamente asombroso. Permite rastrear múltiples servicios (cliente y servidor) y puede unirlos y ayudarlo a analizar todos los detalles. Le permite llegar a la raíz de los problemas realmente rápido. (Porque cuando hay un error de WCF del servidor, es poco probable que el cliente obtenga datos útiles).


He tenido este error cuando uso ''yield return'' para crear una enumeración de los objetos asignados a mi tipo de DataContract .

Llamar a ToList / ToArray en los resultados de rendimiento solucionó el problema y la llamada de servicio funcionó correctamente.


Intente configurar [OperationBehavior()] sobre su implementación del método de interfaz.


Los enums obtienen un atributo DataContract , como cualquier clase, pero no se supone que los valores enum tengan atributos DataMember en ellos.

EnumMember a EnumMember y EnumMember obtener este error inescrutable.



No sé por qué esto puede suceder. pero también tuve problemas similares.

He cambiado mis enums.remove los índices (por ejemplo, ASNOrder = 1, -> ASNOrder,), y no se produjo ningún error.


Ok, finalmente encontré el verdadero problema en mi caso. Parece que exponer enums no es lo mejor del mundo. O bien tengo que establecer un valor predeterminado en ellos, o en su lugar exponer la propiedad como int o cualquier tipo de entero en el que se base mi enum.

Gracias por ayudarme, no tenías manera de saber esto, encontré las enumeraciones en el 3er nivel de mi estructura y sistemáticamente eliminé los miembros de datos uno por uno de la manera en que me enteré. Parece que no soy el único que se encontró con este problema, obviamente este tipo tenía problemas similares :)

http://zianet.dk/blog/2007/11/24/serializing-enums-in-wcf/


Sí, tuve el mismo problema aquí y fue todo con devolver objetos que tenían valores enum. Cambié el DataMember a un int y todo funcionaba statrted.


Si está trabajando con WCF + (EF + POCO), intente configurar,

ObjectContext.ContextOptions.LazyLoadingEnabled = false; ObjectContext.ContextOptions.ProxyCreationEnabled = false;


También tuve el mismo problema (.Net 3.5). Resulta que mi clase base DataContract faltaba un tipo conocido. Es desafortunado que el error de WCF no sea más descriptivo.


esta es en realidad la misma información que su primera descripción de excepción. sería interesante cuál fue la causa original de la excepción de socke. tiene que haber algún tipo de error en el servicio en sí. ¿Puedes localizar dónde ocurre exactamente la excepción whar?

tuve errores similares al tratar de devolver los IEnumerables normales que fueron sobrescritos (fueron marcados como virtuales) por NHibernate, y sustituidos por GenericPersistentBag, que no es serializable. ¿Ha marcado sus miembros de IEnumerable como virtuales debido a nhibernate o algo similar? esto podría explicar tu error.

por cierto. Las excepciones wcf a menudo son bastante sin sentido (lo cual puede ser muy frustrante cuando se rastrea un error;)


Server Error in ''/'' Application. -------------------------------------------------------------------------------- An existing connection was forcibly closed by the remote host Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [SocketException (0x2746): An existing connection was forcibly closed by the remote host] System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) +93 System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) +119 [IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.] System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) +267 System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size) +25 System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead) +306 [WebException: The underlying connection was closed: An unexpected error occurred on a receive.] System.Net.HttpWebRequest.GetResponse() +1532114 System.ServiceModel.Channels.HttpChannelRequest.WaitForReply(TimeSpan timeout) +40 [CommunicationException: An error occurred while receiving the HTTP response to http://Zzzstrukturservice.xxx.dk/ZzzstrukturService.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.] System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +2668969 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +717 xxx.Services.ZzzstrukturServiceClient.ZzzstrukturServiceProxy.IZzzstrukturService.GetMatrixSet(Int32 matrixSetId) +0 xxx.Services.ZzzstrukturServiceClient.ZzzstrukturRepository.GetMatrixSetById(Int32 matrixSetId) in f:/ccnet/work/xxx.Zzzstruktur/1. Presentation Layer/ZzzstrukturServiceClient/ZzzstrukturRepository.cs:90 xxx.yyy.yyyWeb.AnnoncePage.OnLoad(EventArgs e) in f:/ccnet/work/yyyV2/1. Presentation Layer/yyyWeb/Annonce.aspx.cs:40 System.Web.UI.Control.LoadRecursive() +47 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436 -------------------------------------------------------------------------------- Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433