用户工具

站点工具


web:webservice
  • jdk原生JAX-WS
@WebService class Hello { @WebMethod String say(@WebParam String name); } //可选实现接口
Endpoint.publish('http://localhost:8089/ws', new MyServiceImpl());  //http://localhost:8089/ws?wsdl
wsimport -d /h/works/itecheast/light4j/src/test/java -p com.xlongwei.light4j.ws http://localhost:8089/ws?wsdl
new HelloService().getHelloPort().say("hello"); //wsimport会生成HelloService、Hello、Say、SayResponse等类
  • cxf集成spring,支持JAX-WS、JAX-RS
org.apache.cxf:cxf-spring-boot-starter-jaxws
@WebService interface UserService
@WebService(serviceName="userService",endpointInterface) @Component UserServiceImpl implements UserService
@Configuration CxfConfig { @Autowired Bus bus; @Autowired UserService userService;
  @Bean ServletRegistrationBean srb(){ return new ServletRegistrationBean(new CXFServlet(), "/soap/*"); }
  @Bean Endpoint endpoint() { new EndpointImpl(bus, userService).publish("/user"); }
} //http://127.0.0.1:8080/soap/user?wsdl
JaxWsProxyFactoryBean jaxWsProxyFactoryBean = new JaxWsProxyFactoryBean();
jaxWsProxyFactoryBean.setAddress("http://127.0.0.1:8080/soap/user?wsdl")
jaxWsProxyFactoryBean.setServiceClass(UserService.class);
UserService us = (UserService) jaxWsProxyFactoryBean.create();
web/webservice.txt · 最后更改: 2020/06/17 23:05 由 admin