Bonjour à tous,
J'ai mis en place un service WCF qui me permet d'interroger une base de données SqlServer.
Dans ma base de données, j'ai enregistré des fichiers ZIP, à l'aide de la fonctionnalité FILESTREAM de SQL server 2008.
Je n'ai aucun problème pour récupérer mon fichier ZIP avec mon service Web.
Cependant je n'arrive pas à le transmettre au client. J'ai essayé plusieures types de données (byte[], Stream,....) mais sans résultat.
Voila mon opération :
Ma liaison côté serveur :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 [OperationContract] bool ProjetObtenirModele(string sCheminDestination, out byte[] byFichier);
Ma configuration coté client :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 <basicHttpBinding> <binding name="BasicHttpEndpointBinding" closeTimeout="00:25:00" openTimeout="00:25:00" receiveTimeout="00:25:00" sendTimeout="00:25:00" maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text" transferMode="Buffered"> <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> <security mode="None" /> </binding> </basicHttpBinding>
Si je ne modifie pas la propriété maxArrayLength, j'obtien un message d'erreur :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 <?xml version="1.0" encoding="utf-8"?> <configuration> <system.serviceModel> <bindings> <basicHttpBinding> <binding name="NewBinding0" closeTimeout="00:25:00" openTimeout="00:25:00" receiveTimeout="00:25:00" sendTimeout="00:25:00" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" transferMode="Buffered"> <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> </binding> </basicHttpBinding> </bindings> <client> <endpoint address="http://localhost:49821/SERVICE_MICE.svc" binding="basicHttpBinding" bindingConfiguration="NewBinding0" contract="ISERVICE_MICE" name="basicHttpBinding" /> </client> </system.serviceModel> </configuration>
Après avoir mis la propriété maxArrayLength="2147483647", le service web est long à répondre quand j'appel cette opération, puis j'obtien une exception àprès quelques minutes de "patinage":
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 Erreur lors de la désérialisation du corps du message de réponse pour l'opération 'ProjetObtenirModele'. Dépassement du quota maximal pour la longueur de tableau (16384) lors de la lecture des données XML. Ce quota peut être augmenté en modifiant la propriété MaxArrayLength sur l'objet XmlDictionaryReaderQuotas utilisé lors de la création du lecteur XML. Ligne 1, position 9652284. Server stack trace: à System.ServiceModel.Dispatcher.PrimitiveOperationFormatter.DeserializeReply(Message message, Object[] parameters) à System.ServiceModel.Dispatcher.ProxyOperationRuntime.AfterReply(ProxyRpc& rpc) à System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc) à System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) à System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) à System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) Exception rethrown at [0]: à System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) à System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) à ISERVICE_MICE.ProjetObtenirModele(Byte[]& byFichier, String sCheminDestination) à SERVICE_MICEClient.ProjetObtenirModele(Byte[]& byFichier, String sCheminDestination) Inner Exception: Dépassement du quota maximal pour la longueur de tableau (16384) lors de la lecture des données XML. Ce quota peut être augmenté en modifiant la propriété MaxArrayLength sur l'objet XmlDictionaryReaderQuotas utilisé lors de la création du lecteur XML. Ligne 1, position 9652284. à System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, String res, String arg1, String arg2, String arg3) à System.Xml.XmlExceptionHelper.ThrowMaxArrayLengthExceeded(XmlDictionaryReader reader, Int32 maxArrayLength) à System.Xml.XmlBaseReader.ReadContentAsBase64() à System.Xml.XmlDictionaryReader.ReadElementContentAsBase64() à System.ServiceModel.Dispatcher.PrimitiveOperationFormatter.PartInfo.ReadValue(XmlDictionaryReader reader) à System.ServiceModel.Dispatcher.PrimitiveOperationFormatter.DeserializeParameter(XmlDictionaryReader reader, PartInfo part) à System.ServiceModel.Dispatcher.PrimitiveOperationFormatter.DeserializeParameters(XmlDictionaryReader reader, PartInfo[] parts, Object[] parameters) à System.ServiceModel.Dispatcher.PrimitiveOperationFormatter.DeserializeResponse(XmlDictionaryReader reader, Object[] parameters) à System.ServiceModel.Dispatcher.PrimitiveOperationFormatter.DeserializeReply(Message message, Object[] parameters)
Si quelqu'un à une expérience dans le transfert des gros fichiers (20Mo) par un service Web....
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 Une exception non gérée du type 'System.Reflection.TargetInvocationException' s'est produite dans mscorlib.dll Informations supplémentaires*: Une exception a été levée par la cible d'un appel.
Merci d'avance,
Antoine
Partager