Search code examples
c#wcfwindows-phone-7

How to send big image from wp7 to wcf?


I'm trying to send an image to wcf to use OCR. For now, I succeeded in transforming my image into a byte[] and sending it to the server using wcf. Unfortunately, it works for an array whose size is <16Kb and doesn't work for an array >17Kb.

I've already set the readerQuotas and maxArrayLength to its maximum size in web.config on the server size.

Do you know how to send big data to a wcf server, or maybe any library to use OCR directly on wp7?


Solution

  • Finaly solved. You have to update your web.config to allow the server to receive big data. And then you have to use the Stream type in your WCF and byte[] type in your WP7. Types will match and both WCF or WP7 will agree to receive and send it.

    In WCF :

    public string ConvertImgToStringPiece(Stream img)
    {
         //.....
    }
    

    In WP7 :

    Service1Client proxy = new Service1Client();    
    proxy.ConvertImgToStringPieceCompleted += new EventHandler<ConvertImgToStringPieceCompletedEventArgs>(proxy_ConvertImgToStringPieceCompleted);    
    proxy.ConvertImgToStringPieceAsync(b); //b is my Byte[], more thant 17Kb.