简体   繁体   中英

Do I need web service, or Hessian, in this case?

I am a newer in java, and I want to write a bbs. For get a thread info, I design an interface like this:

client request:

http://api.a.com/r?type=thread&id=111

server response:

xml data for this thread

But someone tell me that I should use web service or Hessian here. I don't know what advantage of these and if he is right, please tell me how should I do, thanks!

Depending on your needs, you can/should use one or the other. Web Services it's a wide and common technology, you can implement a webservice in PHP and consume it with a Java client, for example. Thus, if you plan to expose your api to the public and don't want to restrict the client's programming language, you should use web services. BUT web services are heavy and slow (due to SOAP enveloping).

In the other hand, which I think it's your case, if you are doing the whole application and you are developing both the server and the client and can choose a single language (Java) to program both of them, you should go with a Java's native solution. In fact, Hessian it's a lightweight binary HTTP-based protocol, which means it's faster than Web Services.

Let me give you a link, maybe it will help you to understand the topic: http://docs.spring.io/spring/docs/2.5.x/reference/remoting.html#remoting-caucho-protocols

if your are considering for the java then i suggest you to read about axis 2 web service they will work a lot for you . But as per your comment on the answer that you need to generate the web service specially for the mobile domain than you need to generate most of the data in to the json or xml response for that you can use java lib for generating source data int o the specific fornate data.

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