Bonjour ^_^
Je dois migrer un logiciel de VB6 à .Net.
Pour l'envoit de fichier, l'ancien logiciel utilisait INET
J'ai convertit ce code ainsi :
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 Inet.Protocol = icHTTPS Inet.RequestTimeout = 10 Inet.URL = GlobURL Inet.AccessType = icDirect Inet.UserName = varUser Inet.Password = varPass Inet.OpenURL Inet.URL Do DoEvents Loop While Inet.StillExecuting Print #55, "Post" Inet.Execute Inet.URL, "POST", GlobData Do DoEvents Loop While Inet.StillExecuting
Tout va bien jusqu'à ce que j'arrive avec un gros fichier. Si le fichier est trop gros, je reçoit une 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 encoding = New UTF8Encoding() bytes = encoding.GetBytes(data) request = DirectCast(WebRequest.Create("https://www.monurl.com/"), HttpWebRequest) ' Set the header fields. request.Method = "POST" request.ContentType = "text/xml; charset=UTF-8" request.ContentLength = bytes.Length request.UserAgent = "SWX" request.Timeout = System.Threading.Timeout.Infinite ' Need to set certificate policy to allow HTTPS communication ServicePointManager.ServerCertificateValidationCallback = New System.Net.Security.RemoteCertificateValidationCallback(AddressOf CertValidationCallback) ' Post the data newStream = request.GetRequestStream() newStream.WriteTimeout = System.Threading.Timeout.Infinite newStream.Write(bytes, 0, bytes.Length) newStream.Close()J'ai aussi ajouter cela dans mon app.configUnable to write data to the transport connection: An existing connection was forcibly closed by the remote host
Malheureusement j'ai toujours le même problème. J'ai commencer à me demander si ce n'est pas le client qui n'accepte pas ma grosseur de fichier, mais comme cela fonctionnait avec INET, je dois écarter cette possibilité.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 <system.serviceModel> <bindings> <basicHttpBinding> <binding name="HttpStreaming" maxReceivedMessageSize="67108864" maxBufferSize="67108864" maxBufferPoolSize="67108864" transferMode="Streamed"/> </basicHttpBinding> </bindings> </system.serviceModel>
Quelqu'un aurait-il une idée de la prochaine avenue à explorer?
Merci ^_^
Partager