【发布时间】:2011-05-11 20:45:03
【问题描述】:
所以我有一个返回 pdf 流的函数。调用过程获取流并将其写入磁盘(感谢 ServiceGuy!)。正常的VB代码如下:
Public Function GetPDF() As System.IO.FileStream
GetPDF = File.OpenRead("C:\Documents and Settings\jspel903\Desktop\3211LD.pdf")
End Function
现在,无论出于何种原因,当我将该代码放入我的 WCF(见下文)并构建/安装时,它都不会返回任何内容。在我的 WCF 托管在 Windows 服务中之后,调用过程一无所获(我无法对其进行调试或单步执行)。所以我想知道 WCF 是否不会返回 FileStream?
这是 IService:
<ServiceContract()> _
Public Interface IService1
<OperationContract()> _
Function GetPDF() As System.IO.FileStream
'Should return a .pdf file as a stream
End Interface
这是 svc:
Imports System.IO
Public Class Service1
Implements IService1
Public Function GetPDF() As System.IO.FileStream Implements IService1.GetPDF
GetPDF = File.OpenRead("C:\Documents and Settings\jspel903\Desktop\3211LD.pdf")
End Function
End Class
在我看来它应该可以工作。有什么想法吗?
【问题讨论】:
-
您是否将 Binding 的
TransferMode设置为StreamedResponse?您能否也发布您的配置(<system.serviceModel>部分)?
标签: vb.net wcf function filestream