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
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • Looking Beyond JSON
  • Live Streaming Service Primer
  • Introduction to Microservices Messaging Protocols
  • The Evolution of Systems Integration

Trending

  • Bad Software Examples: How Much Can Poor Code Hurt You?
  • Demystifying Project Loom: A Guide to Lightweight Threads in Java
  • Auditing Spring Boot Using JPA, Hibernate, and Spring Data JPA
  • Breaking Down Silos: The Importance of Collaboration in Solution Architecture

Hessian Web Service Protocol - Hello World Example

Peter Karussell user avatar by
Peter Karussell
·
Apr. 13, 09 · Interview
Like (0)
Save
Tweet
Share
29.15K 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 socketconnector@0.0.0.0: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

  • Looking Beyond JSON
  • Live Streaming Service Primer
  • Introduction to Microservices Messaging Protocols
  • The Evolution of Systems Integration

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: