Spring发布WebService
Maven:
org.apache.cxf
cxf-rt-frontend-jaxws
3.0.4
org.apache.cxf
cxf-rt-transports-http
3.0.4
org.apache.neethi
neethi
3.0.3
这里的org.apache.neethi的版本最好是3.0.3 不然你使用了别人的webservice可能会报错 我试过用3.0.2报错
: javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: java.lang.RuntimeException: Cannot create a secure XMLInputFactory
具体原因不清楚
还有记得别加这个
文章图片
image.png
不然还是报错 【Spring发布WebService】
Caused by: org.apache.cxf.BusException: No DestinationFactory was found for the namespace http://schemas.xmlsoap.org/soap/http.
webxml:
CXFService
org.apache.cxf.transport.servlet.CXFServlet
1 CXFService
/ws/*
url-pattern自定义,就是你访问webservice的地址
Springxml:
webservice接口:
package ws.spring.server;
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService
public interface UserWS {
@WebMethod
public UserBean getUserById(int id);
}
webservice实现类 :
package ws.spring.server;
import javax.jws.WebService;
@WebService
public class UserWSImpl implements UserWS {
public UserWSImpl(){
System.out.println("初始化 UserWSImpl");
}
@Override
public UserBean getUserById(int id) {
System.out.println("server getUserById:"+id);
return new UserBean(1, "张三");
}
}
运行输入地址: /ws/自定义的webservice 地址
推荐阅读
- Activiti(一)SpringBoot2集成Activiti6
- SpringBoot调用公共模块的自定义注解失效的解决
- 解决SpringBoot引用别的模块无法注入的问题
- 2018-07-09|2018-07-09 Spring 的DBCP,c3p0
- 图文小编《杨浦、成毅》为你发布!无价之宝随意摆放的公园
- spring|spring boot项目启动websocket
- Spring|Spring Boot 整合 Activiti6.0.0
- Spring集成|Spring集成 Mina
- springboot使用redis缓存
- Spring|Spring 框架之 AOP 原理剖析已经出炉!!!预定的童鞋可以识别下发二维码去看了