本篇介绍使用CXF工具暴露接口,不过多介绍,主要看代码。
实现过程:
1、在pom.xml添加CXF需要jar包:
org.apache.cxf
cxf-core
3.2.5
org.apache.cxf
cxf-rt-frontend-jaxws
3.2.5
org.apache.cxf
cxf-rt-transports-http-jetty
3.2.5
2、改动上篇的Server.java代码即可:
package com.gx.server;
import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
import com.gx.webservice.IHelloWorld;
import com.gx.webservice.impl.HelloWorldImpl;
public class Server {
static String address = "http://127.0.0.1:34563/helloWorld";
public static void main(String[] args) {
System.out.println("web service start");
IHelloWorld implementor = new HelloWorldImpl();
JaxWsServerFactoryBean factoryBean = new JaxWsServerFactoryBean();
factoryBean.setAddress(address); //