DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Building a Config-Driven SOAP/REST Integration Layer: One Service, Many Protocols
  • The Inter-Agent Protocol Problem
  • The Agent Protocol Stack: MCP vs. A2A vs. AG-UI
  • Understanding the Shifting Protocols That Secure AI Agents

Trending

  • GraphRAG in Practice Using Spring AI, Neo4j, and Goodreads Data
  • Why Developers Must Be Part of the Customer Validation Process
  • Add Observability to Your React Native Application in 5 Minutes
  • Exploring A Few Java 25 Language Enhancements

Hessian Web Service Protocol - Hello World Example

By 
Peter Karussell user avatar
Peter Karussell
·
Apr. 13, 09 · Interview
Likes (0)
Comment
Save
Tweet
Share
30.2K Views

Join the DZone community and get the full member experience.

Join For Free

yesterday i took a quick look to the binary communication protocol: hessian . with hessian your admins will not have any troubles with port-activation for your (’desktop’) application, if they have to access remote services (db etc.).

the java implemenation from caucho is released under the apache license 2.0. hessian is well integrated into spring and seems to perform well for version 3.2 (one year old!). an orm tool which supports hessian out of the box is cayenne .

example

now to our hello world example. it is a maven project and you can get it from here (public domain of course …).

if you don’t want to use maven you should get the following jars:
hessian-libs

but maybe you have the same problems with downloading a none-corrupted hessian.jar from caucho (why that?) - then you will be forced to install maven or netbeans.

the usage is simple: in netbeans you can directly open maven projects with the maven plugin. then start the jetty-server: go into the myservlet class and press shift+f6. you should see in the output window:
… info:  logging to stderr via org.mortbay.log.stderrlog
… info:  jetty-6.1.16
… info:  started [email protected]:8080

then go to the client class and press shift+f6. you should see a new window coming up:

hessian-client

change the text and press enter will push the text to the server and get the response text at the bottom of the window updated:
hessian-client-result

now let us understand what is necessary:

  1. an interface which has to be available on the server and on the client side:
    public interface communicationservice {    string communicate(string str);}
  2. an implementation of this interface on the server side:
    public class myservlet extends hessianservlet implements communicationservice {    public string communicate(string str) {        return "hello world! " + str;    }    ...}
    (here only the ‘implements communicationservice’ is important)
  3. now the server code:
    public static void main(string[] args) throws exception {        server server = new server(8080);        context context = new context(server, "/", context.sessions);        context.addservlet(myservlet.class, "/communication-service");        server.start();}
  4. and the client code:
    string url = "http://localhost:8080/communication-service";hessianproxyfactory factory = new hessianproxyfactory();final communicationservice basic = (communicationservice) factory.create(communicationservice.class, url);...resultlabel.settext("server said : " + basic.communicate(field.gettext()));
  5. thats it!

looks really like rpc of java but it is language independent - there are implementations for ruby, phyton … and it seems to be more performant than language independent solutions like xml-rpc. are there other advantages or disadvantages?

Web Service Hessian (Web service protocol) Protocol (object-oriented programming)

Opinions expressed by DZone contributors are their own.

Related

  • Building a Config-Driven SOAP/REST Integration Layer: One Service, Many Protocols
  • The Inter-Agent Protocol Problem
  • The Agent Protocol Stack: MCP vs. A2A vs. AG-UI
  • Understanding the Shifting Protocols That Secure AI Agents

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook