1. Alejandro Reyero
  2. PowerBuilder
  3. Thursday, 19 October 2017 13:21 PM UTC

Hi all.

 

We need to download files (PDFs basically) from an HTTPS server in a recently migrated Windows PB 2017 application. Any clues on how to do this? We have been taking a look at the INET object but seems more suited for classic HTML interaction (form requests).

Any clue or code sample that you can share?

 

Thanks in advance.

Roland Smith Accepted Answer Pending Moderation
  1. Thursday, 19 October 2017 13:43 PM UTC
  2. PowerBuilder
  3. # 1

GetURL can be used to download files but it doesn't support HTTPS.

I have a code example that uses the WinHTTP API functions and it does support HTTPS.

http://www.topwizprogramming.com/freecode_winhttp.html

 

Comment
There are no comments made yet.
Brad Mettee Accepted Answer Pending Moderation
  1. Thursday, 19 October 2017 13:44 PM UTC
  2. PowerBuilder
  3. # 2

SocketTools.com has a suite of Active-X objects that do all types of network connectivity. Once purchased, they're free to distribute with your code. 32 and 64bit versions of the controls are included.

HTTP object can be used in Secure mode to connect and send queries, posts, or retrieve/send files to a remote server. The GetFile method is what you would use to retrieve your file. Help file documents everything you need for each control, method, property, and event. We've been using their tools for 20+ years and they've always worked well.

 

 

Comment
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Thursday, 19 October 2017 14:06 PM UTC
  2. PowerBuilder
  3. # 3

You may use Microsoft Msxml2.XMLHTTP or Msxml2.ServerXMLHTTP ActiveX. https://msdn.microsoft.com/en-us/library/ms759148(v=vs.85).aspx

You need at least the methods "open" (use synchronous call) and "send". You can then check the property "status" and get the response in the property "responseBody". You may also need the response headers (e.g. method "getAllResponseHeaders") to read additional information like the filename.

Comment
There are no comments made yet.
Marco Meoni Accepted Answer Pending Moderation
  1. Friday, 20 October 2017 12:51 PM UTC
  2. PowerBuilder
  3. # 4

Hello,

here below a skeleton that you can adapt following what suggested by Renè.

Cheers,

Marco

--------------

String ls_get_url
String ls_response_text, ls_status_text
long   ll_status_code

OleObject loo_xmlhttp
ls_get_url = "https://localhost/helloworld/filename"

try
  loo_xmlhttp = CREATE oleobject
  If loo_xmlhttp.ConnectToNewObject("Msxml2.XMLHTTP.4.0") <> 0 Then Return

  // Trust the SSL Certificate 
  loo_xmlhttp.setOption(2,'13056') 

  loo_xmlhttp.open ("GET",ls_get_url, false)
  loo_xmlhttp.send()

  //Get response
  ls_status_text = loo_xmlhttp.StatusText
  ll_status_code =  loo_xmlhttp.Status
  if ll_status_code >= 300 then
    MessageBox("HTTP GET Request Failed", ls_response_text)
  else
    ls_response_text = loo_xmlhttp.ResponseText
  end if

  loo_xmlhttp.DisconnectObject()
catch (RuntimeError rte)
end try

Comment
  1. Alejandro Reyero
  2. Monday, 23 October 2017 07:08 AM UTC
Hi guys.



 



This was really helpful, thank you all.



It would be great if Appeon could revamp the current INet implementation to support all these stuff natively, something similar in funtionality to .NET's WebRequest would be great.

  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.