Apache CXF 是一个开源的 Services 框架,CXF 帮助您利用 Frontend 编程 API 来构建和开发 Services .
maven引用cxf:
org.apache.cxf
cxf-rt-frontend-jaxws
3.1.3
org.apache.cxf
cxf-rt-transports-http
3.1.3
1
2
3
4
5
6
7
8
9
10
11
启用cxf,web.xml文件中添加配置如下:
备注:webservice访问路径为:项目访问地址/ws/地址
CXFServlet
org.apache.cxf.transport.servlet.CXFServlet
1
CXFServlet
/ws/*
1
2
3
4
5
6
7
8
9
10
服务端发布webservice接口相关知识如下:
webservice接口(主要使用注解),示例代码如下:
接口(interface)
@WebService(targetNamespace = “urn:sinopec:ecc:fi:tmsno:fx”)
public interface TmsImsWebService {
@WebMethod(operationName = "MT_TMS_ECC_FI_TMSYXNO")
public String tmsNo(@WebParam(name = "TmsYxNo") String tmsNo, @WebParam(name = "CODE") String compCode,
@WebParam(name = "YWRQ") String ywrq);
}
接口实现:
@WebService(endpointInterface = “com.pcitc.cbs.webService.TmsImsWebService”, targetNamespace = “urn:sinopec:ecc:fi:tmsno:fx”)
public class TmsImsWebServiceImpl implements TmsImsWebService {
@Autowired
private TmsConfirmRemainService tmsRemain;
@Override
public String tmsNo(String tmsNo, String compCode, String ywrq) {
String sss = tmsRemain.getTmsStrNo(tmsNo, compCode, ywrq);
return sss;
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
定义接口之后需要发布接口:配置文件如下