Springboot + WebService

OSC_LIRkmx 发布于 01/14 19:28
阅读 26
收藏 1

我是用springboot 框架写的webservice 接口,服务端发布成功,客户端也可以当问到,总之模拟的时候没什么问题,但是在服务端执行Sql语句时报空指针异常了,研究了一天没解决,希望有大神可以指点一下,感激不尽。

1.CXF的注册类 import com.webservice.jsapplication.apply.service.JsService; import com.webservice.jsapplication.apply.service.JsServiceImpl; import org.apache.cxf.Bus; import org.apache.cxf.bus.spring.SpringBus; import org.apache.cxf.endpoint.Server; import org.apache.cxf.jaxws.JaxWsServerFactoryBean; import org.apache.cxf.transport.servlet.CXFServlet; import org.apache.log4j.Logger; import org.springframework.boot.web.servlet.ServletRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class CxfConfig { private static Logger logger = Logger.getLogger(CxfConfig.class); @Bean public ServletRegistrationBean dispatcherServlet() { return new ServletRegistrationBean(new CXFServlet(),"/services/*"); } @Bean(name = Bus.DEFAULT_BUS_ID) public SpringBus springBus() { return new SpringBus(); } @Bean public JsService jsService(){ return new JsServiceImpl(); } @Bean public JaxWsServerFactoryBean jaxWsServerFactoryBean(){ JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean(); factory.setServiceClass(JsServiceImpl.class); factory.setAddress("http://localhost:8001/JsWebService"); Server server = factory.create(); server.start(); logger.info("jsWebService服务启动..."); return factory; } } 2.客户端调用类(Client) package com.webservice.jsapplication.apply; import com.webservice.jsapplication.apply.service.JsService; import org.apache.cxf.jaxws.JaxWsProxyFactoryBean; public class Client { public static void main(String[] args) throws Exception{ JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.setAddress("http://localhost:8001/JsWebService"); factory.setServiceClass(JsService.class); JsService jsService = (JsService) factory.create(); System.out.println(jsService.jsWebService("AAA")); } } 3.
加载中
返回顶部
顶部