0

Is is possible to exchange PDF file as a input for RESTful webservices and also I would like to send PNG image as a response to it. If we can do it through REST services please provide me the references link to implement it using REST services.

kbnsln
  • 21
  • 5

2 Answers2

1

I was able to achieve a similar output by converting the file to string/byte[] data and sending it via REST.

My implementation was in Java and the steps used is outline below

  1. Convert the file on disk to byte[] array (apache common-io can convert the file to byte[] in easy step. Try the IOUtils class)
  2. Encoded the byte[] as String (apache common-codec was used for the encoding)
  3. Wrapped the string data in a model class
  4. Converted the model class to json format (GSON was used for the conversion)
  5. Sent the json data over to the server
  6. The server application reversed the process, and the file was available on the server
0

A rest service isn't the right way for what you want. The input for this kind of services are HTTP request attributes or some kind of pushed data. Maybe it's possible to implement a file upload but it's not typical. For restful services is also common to tell your service how to handle the requested resource via the used request method (GET, POST, PUT, DELETE) The response of rest services is normally some kind of structured text output - for instance json.

All in all rest services seems to me not the way to implement your desired scenario. What about a normal cgi or servlet solution?

OkieOth
  • 3,604
  • 1
  • 19
  • 29
  • Multiple PDF file needs to be handled at one folder level, There is no manual work will be there to upload PDF file to Service. This service should be able to use three different applications. Is it possible to implement using SOAP web services. – kbnsln Mar 02 '16 at 10:00
  • @kbnsln you can implement it with a soap service if your webservice wrap the image response in your soap response, seems so me also not common usage of soap. Personally I would avoid the SOAP or Rest overhead for that what you described in your question. – OkieOth Mar 02 '16 at 10:46