Search code examples
xmlweb-servicesrestcxfrs

Multimedia content in REST responce(XML/JSON)


In my thesis I need to test different architectures. A request to a REST web service developed using Apache CXF and Spring MVC with MySQL as back end serving references(a field in database) to images,audio and video files stored in file system. In the response message, what is the best method to send the content to the client(another application using the service which I developed).

URI: http://www.filmservices.com/film/{id}

A client here is not the end user.

  1. Send the encoded hyperlink's(where the content is stored in the file system) to the client, so that the client renders the response and displays it to the browser.
  2. Use Base64 to encode the message(image,audio,video) and send it to the client.

Main concern is performance.


Solution

  • Based on my thesis work I have some points to make here.

    1. If performance is the main concern, obviously you should choose to store the images in file system and send the links content in the file system.It also depends on the size of the application.If it's a small application storing the images and multimedia content in db is not an issue.

    2. I have observed that XML should be chosen as a payload if the multimedia content is encoded and sent.JSON is a bad option if you are to send encoded byte[] in the payload.

    3. If you are sending multimedia content encoding the byte[] is mandatory. So, applying compression after encoding is better and the size of the payload reduces to an extent.