So I have a function which returns a pdf stream. The calling procedure gets the stream and writes it to disk (thanks ServiceGuy!). Normal VB code is as follows:
Public Function GetPDF() As System.IO.FileStream
GetPDF = File.OpenRead("C:\Documents and Settings\jspel903\Desktop\3211LD.pdf")
End Function
Now, for whatever reason when I put that code in my WCF (see below) and build/install, it won’t return anything. The calling procedure gets nothing after My WCF is hosted in a Windows service (I can’t get it to debug or step into). So I’m wondering if, perhaps, WCFs won’t return a FileStream?
Here’s the IService:
<ServiceContract()> _
Public Interface IService1
<OperationContract()> _
Function GetPDF() As System.IO.FileStream
'Should return a .pdf file as a stream
End Interface
Here’s the 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
Seems to me like it should work. Any ideas?
You probably want to convert your FileStream to a byte array and return that. WCF is generally limited to returning serializable types.