将图像从iOS发送到WCF服务 [英] Send image from iOS to WCF service

查看:116
本文介绍了将图像从iOS发送到WCF服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我想将图像从iOS发送到wcf服务,将其保存在我的Sql server DB中。



所以我做了以下操作,但我无法将数据保存在数据库中。



Hi All,

I want to send an image from iOS to wcf service to save it in my Sql server DB.

so I did the following, but I cannot save the Data in the DB.

-(IBAction)AddMeal:(id)sender{
    UIImage *myImage = imageView.image;
    
    NSString *imgBase = [self encodeToBase64String:myImage]; // encoding the image
    
          NSString *str= @"http://server/ServiceAlizonne.svc/json/";
        str=[str stringByAppendingFormat:@"InsertNewFood/%@" , imgBase];
        str=[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        NSURL *WcfSeviceURL = [NSURL URLWithString:str];
        NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
        [request setURL:WcfSeviceURL];
        
        [request setHTTPMethod:@"POST"];
        
        NSData *respData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
       }





所以这里的问题是我得到一些字符的imgBase值(/ \ + ..)那不叫网络服务。



请你帮帮我,



so the issue here is that I get the imgBase value with some characters (/ \ + ..) that doesn't called the web service .

can you please help me on this please,

推荐答案

而不是像这样发送,尝试发送多部分请求



从iOS发送请求,如这个 [ ^ ]



在服务器端处理它,如这个 [ ^ ](这是一个ac#代码给你举个例子)。



我已经使用它,当我们有一些参数和图像数据或只是简单的一些图像数据时,它非常适合。





希望它有所帮助!
Instead of sending it like this, try sending a multipart request.

Send request from iOS like this[^]

Handle it on server side like this[^] (This is a c# code to give you an example).

I have used it and it works perfect for both when we have some arguments along with image data or just simple some image data.


Hope it helps!


这篇关于将图像从iOS发送到WCF服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆