【发布时间】:2016-11-24 14:11:10
【问题描述】:
我正在开发一个 C# windows 应用程序并尝试将图像文件的字节 [] 发送到 WCF 服务。下面是我在 windows 应用程序中的代码。
private bool SaveVisitorPhoto()
{
byte[] visitorPhotoByte;
using (WebClient webClient = new WebClient())
{
visitorPhotoByte = ImageUtility.ImageToByte(picVisitorPhoto.Image, ImageFormat.Png);
string url = webServiceURL + "SaveVisitorPhoto/" + VisitPIN;
webClient.UploadData(url, visitorPhotoByte);
return true;
}}
[OperationContract]
[WebInvoke(UriTemplate = "SaveVisitorPhoto/{visitPIN}", ResponseFormat = WebMessageFormat.Json)]bool SaveVisitorPhoto(string visitPIN);
现在我不确定如何在 WCF 服务中获取 byte[] 数据,或者有没有其他方法可以实现。
我看到了很多 atricles,但我找不到任何可以将图像数据发送到 WCF 服务的工作示例。让我知道,如果有人做过这方面的工作。
谢谢。
【问题讨论】: