0

Am trying to develop a web service using which we plan to host many services in our application.

We are planning to use HTTPService from Sun to develop the same. I have few doubts regarding the same:

  1. Can we develop a restful webserver using that?

  2. Can the data be passed as a bytestream back and forth to the service?

  3. Any specific potential pitfalls I have to be wary of?

  4. Most imp a good implementation example, so that I get my design right in first go.

  5. I have a sample service in place now. What are the ways that I can test the same?

Thanks a lot in advance.

jabaldonedo
  • 25,822
  • 8
  • 77
  • 77
LPD
  • 2,833
  • 2
  • 29
  • 48

1 Answers1

1

1) Can we develop a restful webserver using that? There is no such concept of restful webserver. You need to host your webservice on a web server. A web server will route the incoming http/https requests to your application. You should configure your web.xml properly to hit the webservice. Generally there is one top level servlet in any web service framework, which handles all the incoming request at a particular url and the pass the request to the web service implentation class.

2) Can the data be passed as a bytestream back and forth to the service? Yes you can take the input stream as an input param to your service. You may have to user Multipart form/mixed param for it. Here is an example:

@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response createFile(@FormDataParam("fileConfig") String strFileConfig, 
            @FormDataParam("file") InputStream file);

3) Any specific potential pitfalls I have to be wary of? Make sure you follow REST specification properly. You represent your entities well and create the right ref-urls. Choose between synchronous and asynchronous services. Any time consuming operation should be exposed as asynchronous service.

4) Most imp a good implementation example, so that I get my design right in first go. It depends on your requirement. Design is simple as mentioned in the first answer. Configure properly top level servlet, web service class, follow rest specs.

5) I have a sample service in place now. What are the ways that I can test the same? You can test it different tools such as JMeter, chrome rest plugin, etc.

Hope it helps!

Juned Ahsan
  • 67,789
  • 12
  • 98
  • 136