応答オブジェクトにファイルを書き込む際に問題が発生しています。ファイルはBase64でエンコードされており、Webサービス経由でASPコードに送信されています。chr(0)に問題がある従来のASP response.writeまたはresponse.Binarywrite
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
BinaryWriteは、1バイトおきに余分なヌル文字を追加しています。それをresponse.writeに変更し、ヌル文字を検出しない場合はヌル文字列を終了しますが、文字列を終了します。
私は余分なnullを追加せずにbinarywriteを使用する方法を探しています。それは文字セットの問題ですか?
ありがとうございました