开发者

Using Classic ASP (vbscript) to write a file but the data comes from a WCF

I have WCF service that returns an object that contains an array of bytes that can be saved as a PDF (my .NET component of this implementation works like a charm, the bytes are saved to a stream and they write out the PDF without issue). I can modify the WCF to return just the bytes if necessary. My question is: How can I get those bytes to the asp page so I can save them. I've spent several hours searching the web for 开发者_如何学Cmethods/help/hints/anything, but have been relatively unsuccessful. I have a method for writing files in asp, but it takes an array of bytes, but I dont know how to get the bytes from the WCF. The only way I've been able to communicate with WCF is to use SOAP type calls and parse the XML that is returned (which is fine for the rest of the page, since I just need the text values that are returned), but this one needs the bytes returned to save the file. (And no, the WCF cannot save the file on its own, it lives on a different server and does not have access to share a drive map or something like that).

Any thoughts/hints/tips/etc would be GREATLY appreciated, Im going insane with this project!

Thanks in advance everyone!


It sounds like you are calling the WCF service and getting a string in return, if not see Calling WCF service by VBScript.

Once you have the string, convert it to a byte sub type(using ChrB()) and save it to a file or write it out to the client.

I found this code sample at Create and work with binary data in ASP/VBScript:

Function StringToMultiByte(S)
  Dim i, MultiByte
  For i=1 To Len(S)
    MultiByte = MultiByte & ChrB(Asc(Mid(S,i,1)))
  Next
  StringToMultiByte = MultiByte
End Function
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜