Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to get started with Hessian

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces you how to get started with Hessian, the content is very detailed, interested friends can use for reference, I hope it can be helpful to you.

Create a web project hessianServer and import hessian-4.0.62.jar

Create Customer to implement Serializable interface

Import java.io.Serializable;public class Customer implements Serializable {private String id; private String name; private String address;...}

Create CustomerServiceImpl

Package com.gwl.crm.service.impl;import com.gwl.crm.model.Customer;import com.gwl.crm.service.CustomerService;import java.util.ArrayList;import java.util.List;public class CustomerServiceImpl implements CustomerService {@ Override public List findAll () {Customer C1 = new Customer ("01", "zhangsan", "beijing"); Customer c2 = new Customer ("02", "lisi", "shenzhen"); List customers = new ArrayList () Customers.add (C1); customers.add (c2); return customers;}}

Configure web.xml

Hessian com.caucho.hessian.server.HessianServlet home-class com.gwl.crm.service.impl.CustomerServiceImpl home-api com.gwl.crm.service.CustomerService hessian/ hessian/customer

Create a client project, import hessian-4.0.62.jar, and copy the Customer and CustomerService from the web project hessianServer into the client project

Import com.caucho.hessian.client.HessianProxyFactory;import java.util.List;public class Main {public static void main (String [] args) throws Exception {HessianProxyFactory factory = new HessianProxyFactory (); CustomerService customerService = (CustomerService) factory.create (CustomerService.class, "http://localhost:8080/hessianServer_war_exploded/hessian/customer"); List customers = customerService.findAll ()) / / output [{address=beijing, name=zhangsan, id=01}, {address=shenzhen, name=lisi, id=02}] System.out.println (customers);}} this is the end of the introduction to Hessian. I hope the above content can be of some help and learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report