Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 6 Monaten, 3 Wochen
Letzter Beitrag:
vor 6 Monaten, 3 Wochen
Beteiligte Autoren:
Michael Drechsel, Fabrice Harari, Arie, ccc2

[WX22] What is the best way to download a binary file via a webservice

Startbeitrag von Michael Drechsel am 26.01.2018 12:28


I changed all my FTP Download procedures in windev to httprequest.
I use a awp site and cut the file in pieces.

The code is:



//Datei öffnen
IF nDateihandle=-1 THEN
stMyDownload_Vorgang.nStatus=5 //Fehler
stMyDownload_Vorgang.sFehlermeldung="Fehler beim der Öffnen der Quelldatei ! "+CR+ErrorInfo(errFullDetails)

//Zeiger positionieren
IF fSeek(nDateihandle,stMyDownload_Vorgang.nMove,fpBeginning)=-1 THEN
stMyDownload_Vorgang.nStatus=5 //Fehler
stMyDownload_Vorgang.sFehlermeldung="Fehler bei der Positionierung der Quelldatei ! "+CR+ErrorInfo(errFullDetails)


stMyDownload_Vorgang.sFehlermeldung="Fehler beim Download Vorgang !"+CR+ExceptionInfo(errFullDetails)



It works, but it is not so fast as it could be. Has anybody found a better way to transfer binary files via HTML in windev ?


Hi Michael,

in theory, if you are using a post type httprequest, you can transfer binary content directly (I haven't found the time to test that correctly yet)...

So putting your file in a buffer and sending it back 'as is' should be enough...

That part works fine on the server side, with a browser on the other side (I'm using that for the download part of my site), what I haven't tested is the httprequest part on the client side.

So, again in theory, as the content is sent as is, there is no size increase (serialize) and the speed should be maximum.

Best regards

von Fabrice Harari - am 26.01.2018 12:35
Hi Fabrice,

my code at client side is:

cMyRequest is httpRequest
cMyResponse is httpResponse
cMyRequest..URL = sWebserviceAdresse+"/PLAN_IT_2015_WEB/DE/"+Replace("PAGE_"+sProzedurename,"_","-")+".awp"
cMyRequest..TimeOut=10*60*1000 //10 min

cMyResponse = HTTPSend(cMyRequest)

What should I change to change it to a "post" request ?

the help says:

: Optional character string (with quotes)

HTTP message that will be sent to the server. This parameter can be specified only for a request for sending messages (POST request). The message to send must comply with the HTTP protocol used. If this parameter is specified and if it is not empty, it is a POST request; otherwise, it is a GET request (everything else is automatic).

I don´t understand this ......

von Michael Drechsel - am 26.01.2018 12:51
Hi Michael,

what the help means is that the switch for the post mode is simply to use that optional parameter to send your parameters to your awp page (instead of setting them in the URL)...

When you do that, the request is using the post protocol and you should get your file directly in the result of the query.

Another advantage of the POST mode is that it is NOT limited in the size of the packets transported, when the get mode is...

Best regards

von Fabrice Harari - am 26.01.2018 13:57
Ok, thx.

Last question:

If the server sends the pure binary file back, how can I receive additional information like checksum, result etc at client side ?

Something like that:

buffer =file+";"+checksum+";"+true ?

von Michael Drechsel - am 26.01.2018 14:05

I would advise that you put everything at the beginning of the buffer, something like:
Buffer = Checksum=Value+CR+Result=True+cr+FileContent

this way, it's easy to get the position of the second CR, and use left and right to separate things

Best regards

von Fabrice Harari - am 26.01.2018 14:52
Yes, sure. Many thx Fabrice

von Michael Drechsel - am 26.01.2018 14:54
Hi Michael,

for webservice + json , the common method is convert the buffer to base64. if corruption, you won't be able to decode it back

von ccc2 - am 26.01.2018 16:50
Hi ccc,

yes, I use it (see my code in the first post)

I think, the result of serialize() from the awp site is a base64 string. The problem is, that this file is ~ 30 percent larger as the original file and so this transfer is slower as from a browser.

I am looking for a fast html based download between windev and the awp site from webdev with small overhead.

von Michael Drechsel - am 26.01.2018 17:05

you could compress the file first and decompress it at he client. It depends on the type of file if it will help you.
I use this for instance to 'download' sqlite database to android devices. These DB-file are zipped up to a rate of 60-90%

von Arie - am 26.01.2018 17:28
Hi Arie,

my files are most pdf, dwg, dgn files. Indeed I use the compression, but not in every case is that a solution.
I would preferred a "pure" download / Upload of binary files via HTML.

von Michael Drechsel - am 26.01.2018 17:34
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.