3

In my IOS app i need o send a image to ASP.NET Web Service . I am trying to the image in bytes form & then convert it back to image form on server side. Now i am using these line to convert image to bytes in IOS :

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

this line give a bytes of 734,775 word, which is too much, so it can not be send a soap request . So , now how can i acieve this goal ??????

when call the service usiong soap request then it gives me this error :

<?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>

I am making an app for chating , so on registeration of user i have to upload the user image to web server and when it search for people around him/her, then also i want to return imae from the web service how can i do thse two things ? First put image on web server & then retrieve from web server . Thanks A lot

HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
pasha pash
  • 99
  • 11
  • Hii have you found solution for your question? If so, please help me in this question. http://stackoverflow.com/questions/29077775/upload-image-from-iphone-to-server-using-wcf-service-using-soap – sreekanthk Mar 17 '15 at 06:19
  • 1
    @pasha pash - I was also facing the same problem and the below answer was what I did to solve the issue.Feel free to get back to me in case if you problem remains unsolved – Durai Amuthan.H Mar 24 '15 at 16:27

1 Answers1

3
  • You can reduce the memory footage of the image using JPEG image compression

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

    where quality is between 0.0 and 1.0

  • Don't send the image as raw binary over the internet turn the binary into base64 string

because some media are made for streaming text. You never know some protocols may interpret your binary data as control characters , or your binary data could be screwed up because the underlying protocol might think that you've entered a special character combination.

Here is the link on how to convert into base64

  • As you are using IIS for hosting your application, then the default upload file size if 4MB. To increase it, please use this below section in your web.config

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

    For IIS7 and above, you also need to add the lines below:

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

Note: maxAllowedContentLength is measured in bytes while maxRequestLength is measured in kilobytes, which is why the values differ in this config example. (Both are equivalent to 1 GB.)

Here is an answer for another question that'd be helpful to you

Community
  • 1
  • 1
Durai Amuthan.H
  • 31,670
  • 10
  • 160
  • 241