从IOS发送图像到asp.net web服务

在我的IOS应用程序中,我需要将图像发送到ASP.NET Web服务。 我想以字节forms的图像,然后将其转换回服务器端的图像forms。 现在我正在使用这些行将图像转换为IOS中的字节:

NSData *imageData=UIImagePNGRepresentation([Mybutton currentBackgroundImage]); 

这一行给出了734775字节的字节,这太多了,所以不能发送肥皂请求。 那么,现在我怎么才能达到这个目标呢?

当调用服务的us soap请求时,它给了我这个错误:

 <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body><soap:Fault> <faultcode>soap:Server</faultcode> <faultstring> System.Web.Services.Protocols.SoapException: There was an exception running the extensions specified in the config file. ---&gt; System.Web.HttpException: Maximum request length exceeded. at System.Web.HttpRequest.GetEntireRawContent() at System.Web.HttpRequest.get_InputStream() at System.Web.Services.Protocols.SoapServerProtocol.Initialize() --- End of inner exception stack trace --- at System.Web.Services.Protocols.SoapServerProtocol.Initialize() at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean&amp; abortProcessing) </faultstring> <detail /> </soap:Fault> </soap:Body> </soap:Envelope> 

我正在做一个应用程序的聊天,所以用户的注册我必须上传用户图像到networking服务器,当它search周围的人/她,那么我也想从networking服务返回imae我怎么能这样做两件事情 ? 首先把图像放在networking服务器上,然后从networking服务器上检索。 非常感谢

  • 您可以使用JPEG图像压缩来减less图像的内存镜头

     lowResolutionImage = [UIImage imageWithData:UIImageJPEGRepresentation(highResImage, quality)]; 

    质量介于0.0和1.0之间

  • 不要通过互联网将原始二进制图像发送到base64string

因为有些媒体是为stream式文本而制作的。 你永远不知道一些协议可能会将你的二进制数据解释为控制字符,或者你的二进制数据可能被搞砸了,因为底层协议可能认为你已经input了一个特殊的字符组合。

这里是如何转换成base64的链接

  • 由于您正在使用IIS来托pipe您的应用程序,因此默认的上传文件大小为4MB。 要增加它,请在web.config中使用下面的部分

     <configuration> <system.web> <httpRuntime maxRequestLength="1048576" /> </system.web> </configuration> 

    对于IIS7及以上版本,您还需要添加以下几行:

     <system.webServer> <security> <requestFiltering> <requestLimits maxAllowedContentLength="1073741824" /> </requestFiltering> </security> 

注意:maxAllowedContentLength以字节为单位,而maxRequestLength以千字节为单位,这就是configuration示例中值不同的原因。 (两者相当于1 GB)

这是另一个对你有帮助的问题的答案