c# - 将图像从 iPhone 上传到 WCF 服务

标签 c# iphone objective-c wcf

我正在尝试构建一个 iPhone 应用程序和 c# WCF 服务以将图像上传到 SQL 服务数据库。

我的应用程序将图像分解为 NSData 并使用以下代码发布到 WCF 服务:

NSData *imageData = UIImageJPEGRepresentation(self.image, 90);

NSURL *url = [NSURL URLWithString:@"http://example.com/ImageDiaryService.svc/json/AddMediaItem"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setPostValue:@"Test" forKey:@"Name"];
[request setPostValue:@"Test description." forKey:@"Description"];
[request setPostValue:@"JPEG" forKey:@"ImageType"];
[request setPostValue:@"iPhone" forKey:@"MediaType"];

[request setData:imageData withFileName:@"myphoto.jpg" andContentType:@"image/jpeg" forKey:@"ImageData"];

[request setDidFinishSelector:@selector(uploadFinished:)];
[request setDidFailSelector:@selector(uploadFailed:)];
[request setDelegate:self];
[request startAsynchronous];

我遇到的问题是网络服务。我不确定应该从应用程序 POST 接收什么类型的数据。我尝试过以字节数组的形式接收它,但这不起作用。

我的 WCF 服务是 REST 服务。

非常感谢任何帮助。

最佳答案

尝试将其作为流接收。博客文章位于http://blogs.msdn.com/b/carlosfigueira/archive/2008/04/17/wcf-raw-programming-model-receiving-arbitrary-data.aspx演示如何在 WCF REST 服务中接收任意数据。

关于c# - 将图像从 iPhone 上传到 WCF 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6011595/

相关文章:

c# - 使用跟踪监听器重定向所有调试输出

iPhone UITableView 在顶部添加内容无需滚动

iphone - 使用平移的 UIImageView 移动不完全平滑

iphone - Core Motion 错误 102 是什么意思?

ios - 我应该为手机和平板电脑设备制作一款应用程序,还是为每种设备制作一款应用程序?

iphone - 是否可以获取 UITableView 中单元格的所有索引路径的数组?

iphone - 无法使用 CJJsonSerializer 序列化 NSDate

c# - ManagedCuda 和 __constant__ 变量

c# - TabStop 不工作

c# - 在泛型方法中实例化 Wrapper 对象