Silverlight 3 WCF upload fichier
Bonjour,
Je développe une application Silverlight 3 qui doit faire un upload de fichier vers un serveur, pour cela j'utilise un WCF.
Dans l'application Silverlight :
Code:
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 29 30
|
public void ExecuteParcourirBoutonCommand()
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Image files (*.xls;*.xlsx)|*.xls;*.xlsx";
openFileDialog.Multiselect = false;
bool? resultDialog = openFileDialog.ShowDialog();
if (resultDialog == true)
{
byte[] bytes;
using (Stream str = openFileDialog.File.OpenRead())
{
bytes = new Byte[str.Length];
str.Read(bytes, 0, bytes.Length);
}
CreateUploadFile(openFileDialog.File.Name, bytes);
PublipostageFile = openFileDialog.File.Name;
}
}
private void CreateUploadFile(string fileName, byte[] buffer)
{
Service1Client client = new Service1Client();
client.UploadFileCompleted += new EventHandler<AsyncCompletedEventArgs>(UploadFile);
client.UploadFileAsync(fileName, buffer);
}
void UploadFile(object sender, AsyncCompletedEventArgs e)
{
} |
Et voici le code du WCF :
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
public void UploadFile(string fileName, byte[] input)
{
new LogCall(delegate
{
string Path = "XXXXX";
using (FileStream fs = File.Create(string.Format("{0}{1}", Path, fileName)))
{
fs.Write(input, 0, input.Length);
}
});
} |
Et le web.config du WCF :
Code:
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 29 30 31 32 33 34 35 36 37 38
|
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="Binding1" maxBufferSize="334217728" maxBufferPoolSize="52428800" maxReceivedMessageSize="334217728" transferMode="Streamed">
<readerQuotas maxArrayLength="100000000" maxStringContentLength="100000000"/>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="Appli.WCFService.Service1" behaviorConfiguration="Appli.WCFService.Service1Behavior">
<endpoint address="" binding="basicHttpBinding" contract="DataPrintBox.WCFService.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Appli.WCFService.Service1Behavior">
<!-- Pour éviter la divulgation des informations sur les métadonnées, définissez la valeur ci-dessous sur false et supprimez le point de terminaison des métadonnées ci-dessus avant le déploiement -->
<serviceMetadata httpGetEnabled="true" />
<serviceCredentials>
<clientCertificate>
<authentication mapClientCertificateToWindowsAccount="true" />
</clientCertificate>
</serviceCredentials>
<!-- Pour recevoir les détails d'exception des erreurs à des fins de débogage, définissez la valeur ci-dessous sur true. Définissez-la sur false avant le déploiement pour éviter la divulgation des informations d'exception -->
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel> |
Ce code marche très bien pour l'envoi de fichiers de petites tailles mais pour un fichier de 28Ko ça ne marche plus.
Il me fait une exception
Citation:
Le serveur distant a retourné une erreur : NotFound.
(Pas d'éxception dans les log du WCF).
Manifestement c'est un problème de taille mais j'ai réglé le web.config pour envoyer des fichiers de grandes tailles.
Quelqu'un a une idée ?
Merci