I have a Service that generates a PDF and returns the bytes of it:
The Service when run on the web returns this:
<?xml version="1.0" encoding="UTF-8"?>
<base64Binary xmlns="http://...com/">JVBERi0xLjMKJcfsj6IKNSAwIG9iago8PC9MZW5ndGggNiAwIFIvRmlsdGVyIC9GbGF0ZURlY29kZT4+CnN0cmVhbQp4nK2VXW+bMBSGlRgCgQhoCSWN083dh7RNKvUXBt9O2w9oFWk33FXaqmlkSvb...PmVuZG9iagp4cmVmCjAgMjIKMDAwMDAwMDAwMCA2NTUzNSBmIAowMDAwMDAwOTgzIDAwMDAwIG4gCjAwMDAwMzkzOTcgMDAwMDAgbiAKMDAwMDAwMDkxNCAwMDAwMCBuIAowMDAwMDAwNzI5IDAwMDAwIG4gCjAwMDAwMDAwMTUgMDAwMDAgbiAKMDAwMDAwMDcxMCAwMDAwMCBuIAowMDAwMDEzOTA0IDAwMDAwIG4gCjAwMDAwMTM3NTYgMDAwMDAgbiAKMDAwMDAwMTAzMSAwMDAwMCBuIAowMDAwMDAxMTE5IDAwMDAwIG4gCjAwMDAwMjgzODMgMDAwMDAgbiAKMDAwMDAyODE3NCAwMDAwMCBuIAowMDAwMDM4ODU1IDAwMDAwIG4gCjAwMDAwMTQyNjAgMDAwMDAgbiAKMDAwMDAxNDA1MSAwMDAwMCBuIAowMDAwMDM5MTA2IDAwMDAwIG4gCjAwMDAwMTM2NTEgMDAwMDAgbiAKMDAwMDAxMzY4MSAwMDAwMCBuIAowMDAwMDEzNzEzIDAwMDAwIG4gCjAwMDAwMjgxNTIgMDAwMDAgbiAKMDAwMDAzODgzMyAwMDAwMCBuIAp0cmFpbGVyCjw8IC9TaXplIDIyIC9Sb290IDEgMCBSIC9JbmZvIDIgMCBSCj4+CnN0YXJ0eHJlZgozOTU3MgolJUVPRgo=</base64Binary>
On another page I call this service and then I'll make a response to download the pdf:
<%
If Len(request("ID")) > 0 Then
ID = request("ID")
Else
ID = -1
End If
if len(Request("IDMercado"))>0 then
IDMercado = request("IDMercado")
else
IDMercado = "PT"
end if
If ID <> -1 Then
Set objRequest = Server.createobject("MSXML2.XMLHTTP")
WebserviceUrl="http://linkparaoserviço..."
Method = "GenerateCertificado"
Parameters = "ID=" & ID & "&IDMercado=" & IDMercado
With objRequest
.open "GET", WebserviceUrl & "/" & Method & "?" & Parameters, False
.setRequestHeader "Content-Type", "charset=utf-8"
.setRequestHeader "SOAPAction", WebserviceUrl & "/" & Method
.send
End With
PDF = objRequest.responseBody
Response.Clear
Response.ContentType = "application/pdf"
Response.AddHeader "Content-Disposition", "attachment; filename= Certificado " & ID & ".pdf"
Response.CacheControl = "no-cache, no-store, must-revalidate"
Response.BinaryWrite PDF
Response.End
End If
window.close
%>
However, when the download is done when trying to open the PDF the following error appears:
Failed to Load PDF Document
What am I doing wrong?