私は次のものを持っています:
パブリックインターフェイスINorthwindSvc
<OperationContract()>
<WebGet(UriTemplate:="EmployeePictureBytes?id={EmpId}")>
Function GetEmployeePictureBytesById(ByVal EmpId As String) As Byte()
エンドインターフェイス
私は次のように(EF 4.0を使用して)メソッドを実装しました:
Public Function GetEmployeePictureBytesById(ByVal EmpId As String) As Byte() Implements INorthwindSvc.GetEmployeePictureBytesById
Dim ctxt As New NorthwindEntities
Dim q = From c In ctxt.Employees
Where c.EmployeeID = EmpId
Select c.Photo
Return q.FirstOrDefault
End Function
ブラウザから操作にアクセスするとバイトを受信できます。次のようにWinClientを使用して同じものにアクセスしようとすると(インラインで示されているようにエラーが発生します):
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim o As New WebClient
Dim b() As Byte = o.DownloadData(New Uri("http://localhost:8732/WcfWebHttpSvcLib/rest/EmployeePictureBytes?id=2"))
Dim ms As New MemoryStream()
ms.Write(b, 0, b.Length)
Dim original As New System.Drawing.Bitmap(ms) 'error: parameter is not valid
End Sub
Image.FromStreamを使用して同じことを試しました。しかし、それでも運はありません。
誰かがこれについて私を助けることができますか?
ありがとう