简体   繁体   中英

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?

如果所有其他方法都失败了,请以16Kb的片段发送,然后发送“全部完成”消息(必要时重新组装)

我不知道这是否适用于WP7,但是使用WCF,您还可以使用流来上传更大量的数据。

Bit of a hack but howabout sending it with a HTTP post if it isn't too big? or alternatively changing the webservice so it accepts a blob? (the current array limitation is a limit on the array datatype in the W3C spec)

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.

You can try using a WCF session. The key thing to remember is that sessions in WCF are different than normal sessions we use for Internet programming. It's basically a call to a method that starts the session, any interim calls, and then a final one that ends the session. You could have a service call that starts the session, send chunks of the image, and then call the last one which closes the session and will return whatever you need.

http://msdn.microsoft.com/en-us/library/ms733040.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM