Ma question est similaire à this mais avec une différence intéressante. J'ai défini toutes les valeurs explicitement et cela ne fonctionne toujours pas. Aussi, j'essaie d'éviter les attributs du contrat, si possible.Le client WCF échoue lors de la définition explicite des valeurs enum
Alors, à quoi tout cela ressemble. Je définis un contrat qui a une propriété de type enum. Le ENUM est
public enum ErrorCodes
{
GeneralError = 1,
ValidationError = 2,
AuthenticationError = 3
}
Et puis échoue client errror:
System.ServiceModel.CommunicationException: An error occurred while receiving the HTTP response to http://localhost/MyTestAppService/SomeService.svc/soap. 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.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory`1.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`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.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.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 MyTestApp.ISomeService.TestMethod(TestRequest request)
Quand je supprime toutes les valeurs explicites, cela fonctionne:
public enum ErrorCodes
{
GeneralError,
ValidationError,
AuthenticationError
}
Avez-vous décoré les énumérations avec [EnumMember (Value = "1")] ', selon la question liée? – Tim
non, j'essaie de l'éviter – neleus
Pourquoi? La cause sous-jacente de votre problème est probablement une erreur de sérialisation, alors pourquoi voulez-vous éviter la famille d'attributs '[DataContract]'? – Tim