Join The Works program to have access to the most current content, and to be able to ask questions and get answers from Revelation staff and the Revelation community

At 07 FEB 2023 05:04:48PM Bruce Cameron wrote:

Hello,

I'm using Msxml2.ServerXMLHTTP.6.0 and OLE to GET a PDF file from an outside (FannieMae) API service.

All is good until I get the PDF string (using Resptext = OleGetProperty(OleObj,'responseText') of data.

Note: I also tried 'responseBody' but it is all question marks)

Apparently it is in a format (binary maybe?) that I am not sure how to handle at this stage so that I can OSwrite it out to a .PDF and access/view.

Suggestions or comments on how to rectify?

Thanks!


At 07 FEB 2023 05:24PM Donald Bakke wrote:

Hello,

I'm using Msxml2.ServerXMLHTTP.6.0 and OLE to GET a PDF file from an outside (FannieMae) API service.

All is good until I get the PDF string (using Resptext = OleGetProperty(OleObj,'responseText') of data.

Note: I also tried 'responseBody' but it is all question marks)

Apparently it is in a format (binary maybe?) that I am not sure how to handle at this stage so that I can OSwrite it out to a .PDF and access/view.

Suggestions or comments on how to rectify?

Thanks!

You have to specify 'blob' as the responseType and then use the responseBody property to get the data.

However…I don't think the native OLE/COM functions will support this. We modified SRP_COM to to resolve this problem.

This is also built into our SendHTTPRequest service. I don't recall if you have that product.

Don Bakke

SRP Computer Solutions, Inc.


At 08 FEB 2023 12:09PM Bruce Cameron wrote:

Hi Don,

Thanks for the reply. To my knowledge we do not have that product.

Quick question for you or anyone.

If I can get the "source side" to return the PDF data string back as Base64 encoded, could I just receive it in base64 and then…

OSwrite Base64decode(PDFFileBack) …

??


At 08 FEB 2023 12:14PM Carl Pates wrote:

Bruce,

Another option you have for 32-bit OI is to use the MS Scripting Control (OCX) - then you can write your OLE code in VB or JavaScript and pass whatever results you want back to OI that way.

Bob Carten would probably be a good source of example code if you can't find anything here on this technique.

Regards

Carl Pates


At 08 FEB 2023 12:30PM Donald Bakke wrote:

Hi Don,

Thanks for the reply. To my knowledge we do not have that product.

Quick question for you or anyone.

If I can get the "source side" to return the PDF data string back as Base64 encoded, could I just receive it in base64 and then…

OSwrite Base64decode(PDFFileBack) …

??

Just to be clear, you can replace the OLE/COM functions with SRP_COM (which you should already have) with relative ease.

If you can get the data sent as Base64 then that would also work.

Don Bakke

SRP Computer Solutions, Inc.


At 08 FEB 2023 01:17PM bob carten wrote:

Hi Bruce,

As Carl says, you can probably use the scripting host to get what you want. Below is an untested, error-handling free example, translated from something I found on stackoverflow. You are can work your way through this to make it production ready, or use the component Don is offering, which is already mature.

function downloadPdf(url, saveFileName)

/*

**  download, save a pdf

**  See https://stackoverflow.com/questions/33879738/download-and-save-a-webpage-using-vbscript

**

**  02-08-23  rjc  Created

*/

equ crlf$ to \0D0A\



rcvdLen = 0

script = ''

script<-1> = 'function downloadPdf(url, saveFileName)'

script<-1> = 'dim xHttp: Set xHttp = createobject("Microsoft.XMLHTTP")'

script<-1> = 'dim bStrm: Set bStrm = createobject("Adodb.Stream")'

script<-1> = 'xHttp.Open "GET", url, False'

script<-1> = 'xHttp.Send'

script<-1> = ''

script<-1> = 'with bStrm'

script<-1> = '    .type = 1'

script<-1> = '    .open'

script<-1> = '    .write xHttp.responseBody'

script<-1> = '    .savetofile saveFileName, 2 '

script<-1> = 'end with'

script<-1> = ''

script<-1> = 'downloadPdf = bStrm.size'

script<-1> = 'end function'





swap @fm with crlf$ in script



oScript = OLECreateInstance( 'MSScriptControl.ScriptControl')

oScript->Language = 'VBScript'

olestat = olestatus()



if oleStat else

   x = oScript->AddCode( script)

   olestat = olestatus()

end



if oleStat else

   oCode = oScript->CodeObject

   rcvdLen = oCode->downloadPdf(url, saveFileName)

end

return rcvdLen


At 08 FEB 2023 01:52PM Bruce Cameron wrote:

Thank you all!

I'll try the base 64 encoded route first and then the SRP_COM.

Bob/Carl - Thanks - I have concerns about users rights and permissions with scripting (something I have no control over). We've turned off VB scripting in favor of the OLE controls over the last few years.

View this thread on the Works forum...

  • third_party_content/community/commentary/forums_works/67931dc2b26efd4eac504ff063715fff.txt
  • Last modified: 2024/05/23 12:38
  • by 127.0.0.1