I am having an issue with writing a file to the response object. The file is Base64 encoded and is being sent to the ASP code via a web service.
dim contentType, fileName
filename = request("FileName")
contentType = request("ContentType")
If Not Response.isClientConnected Then
Response.end
End If
Response.buffer = true
Response.Clear
Response.Addheader "Content-Disposition", "attachment; filename=" & filename
Response.contenttype = contentType
dim oSoapClient
Set oSoapClient = Server.CreateObject("MSSOAP.SoapClient")
oSoapClient.ClientProperty("ServerHTTPRequest") = True
oSoapClient.mssoapinit "http://myWS/test.asmx?WSDL"
dim sRequest, sResponse
sRequest = "<Root><Attachment id=""" & Request("ID") & """/></Root>"
sResponse = oSoapClient.GetAttachment(sRequest)
Dim oXML: Set oXML = LoadXMLString(sResponse)
Dim oAttachment
set oAttachment = oXML.SelectSingleNode("/Root/Attachment")
if not oAttachment is nothing then
Response.Binarywrite(Base64Decode(oAttachment.attributes.getNamedItem("BinaryData").value))
End if
Response.End
The BinaryWrite is adding extra null characters every other byte. Change it to response.write and it does not put the nulls but terminates the string if a null character is found.
I'm looking for a method to use the binarywrite without it adding the extra nulls. Is it a charset issue?
Thanks