FoxPro Programming
VFP call to URL and check result
Gravatar is a globally recognized avatar based on your email address. VFP call to URL and check result
  Ed Lennon
  All
  Mar 15, 2023 @ 01:06pm

Hi all,

I am still using VFP 7.0 on our legacy application. I have an update where I need to call a URL and check the result which will either be OK or ERROR. I do not want any UI as a result of this URL call.

I began this task by using a utility written by Drew Speedie that was copied from or based on a FoxPro Advisor article by Rick back in March 1998. That utility essentially calls ShellExecute(). The issue with this method is that I don't want to launch a browser that is visible to the user which this method is doing. I only want to pass the URL and then check the result with no UI.

I then tried to use Rick's example of using WINHTTP.prg which works just wonderfully at the command window, exactly as I need. I pass the URL and I get the result back in a variable that I can check.

However, when I compile the WINHTTP.prg into my .EXE file, I get an error on the following line of code:

loHttp.Send()

I can't figure out why this happens in the .EXE but not at the command window.

Is there a better way to accomplish what I am trying to do?

Thank you in advance for any advice you may have to offer.

Gravatar is a globally recognized avatar based on your email address. re: VFP call to URL and check result
  Rick Strahl
  Ed Lennon
  Mar 15, 2023 @ 02:42pm

... and the error is?

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: VFP call to URL and check result
  Ed Lennon
  Rick Strahl
  Mar 15, 2023 @ 08:21pm

Ricky,

Thanks for your reply! Yeah the error message might help!

This is the error that I am getting in the .EXE:

OLE IDispatch exception code 0 from WinHttp.WinHttpRequest: The host name in the certificate is invalid or does not match

Thanks, Ed

Gravatar is a globally recognized avatar based on your email address. re: VFP call to URL and check result
  Rick Strahl
  Ed Lennon
  Mar 16, 2023 @ 01:33pm

Bad certificate on the server most likely... you'll have to get the certificate fixed.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: VFP call to URL and check result
  Ed Lennon
  Rick Strahl
  Mar 16, 2023 @ 04:36pm

Rick,

Thanks again for your reply! Based on your last reply, I tried a test call to the URL on our production server instead of our development server and the error did not occur.

I didn't know what could have been causing the error as it worked from a VFP command window on the same machine that the .EXE errors on.

Thanks again for your help!

Gravatar is a globally recognized avatar based on your email address. re: VFP call to URL and check result
  Rick Strahl
  Ed Lennon
  Mar 16, 2023 @ 04:39pm

Is it an older version of Windows? You might be running into TLS 1.2 requirements that don't work on old versions of Windows (or not without tweaking settings).

More info here:

Applies to non-Web Connection stuff as well.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: VFP call to URL and check result
  Ed Lennon
  Rick Strahl
  Mar 16, 2023 @ 07:46pm

The Dev machine is running Windows 10 Pro.

Gravatar is a globally recognized avatar based on your email address. re: VFP call to URL and check result
  Rick Strahl
  Ed Lennon
  Mar 18, 2023 @ 02:43pm

Don't know then...

Certainly seems base on the error there's some issue with the certificate and the SSL connection. Make sure you're using the correct domain name and not an IP address or localhost or alias. Certificate and domain used have to match exactly.

+++ Rick ---

© 1996-2024