本文主要是介绍JAX-WS - Handler详解,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
一、Handler说明
Handler用于处理Soap消息,如控制Header(如隐式的添加用户信息等)
Handler分成LogicalHandler和SOAPHandler,常用为SOAPHandler;客户端先处理LogicalHeader再处理SOAPHandler,服务器反之
二、开始前的准备
1、服务端
(1)接口:
@WebService
public interface UserService {@WebResult(name="registerResult")public String register(@WebParam(name="user") User user);
}
(2)实现:
@WebService(endpointInterface="com.xilen.jws.UserService", serviceName="UserServiceImplService")
public class UserServiceImpl implements UserService{@Overridepublic String register(User user) {System.out.println(user);return user.getName() + ", registered!";}}
(3)启动:
public class StartMain {public static void main(String[] args) {Endpoint.publish("http://localhost:8888/userinfo", new UserServiceImpl());}
}
2、客户端
(1) 通过wsimport生成相关代码后,调用服务端编码:
public class Client {public static void main(String[] args) {UserServiceImplService usis = new UserServiceImplService();UserService service = usis.getUserServiceImplPort();User user = new User();user.setId(1);user.setName("admin");user.setPass("12345");System.out.println(servic
这篇关于JAX-WS - Handler详解的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!