Consuming WCF REST service with Android is very slow

I have a WCF REST service built using C # and it returns an image as part of the processor intensive work. The client runs on Android (Java). By default, it returns a JSON text object that looks something like this:

{"d", [9,0,77,12,11, ...]}

These are image bytes. Good. However, all decisions to decode this JSON are unbearably slow. I tried Gson, Jackson and the built-in JSONObject class for Android. I have no idea why they are so slow.

As an alternative solution, I have a REST service that returns a GUID, and then this GUID can be used by the Android client to go to a regular URL, which serves as an ordinary binary stream for the image, through the MVC controller.

This works well, and it is quickly and fairly easily handled on the Android side. However, it feels a bit shredded and a kind of violation of REST design principles.

Am I missing something? Is there a better way to do this?

+3
source share
4 answers

How about your REST service returning Redirect 303 with a Location header that has a URL that points to an image? Or why not just return the bytes directly from the first URL?

Regarding RESTful or not, returning a JSON-encoded image does not conform to the spirit of the REST self-describing constraint.

, , , image/* .

+5

, . , java json, . , .

, . , XML, blob-.

0

, URL- , , , PNG. , JSON, , , .

0

There is an excellent discussion about developing a leisure client application on the Google IO 2010 Android platform.

http://www.youtube.com/watch?v=xHXn3Kg2IQE

This session will introduce architectural considerations for developing RESTful applications on the Android platform. It focuses on design patterns, platform integration, and performance specific to the Android platform.

Great resource and it should watch.

0
source

Source: https://habr.com/ru/post/1762519/


All Articles