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
具体原因不清楚
还有记得别加这个
Spring发布WebService
文章图片
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 1CXFService /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 地址

    推荐阅读