/**
*
*/
package lee;
import java.io.FileNotFoundException;
import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
import org.fkjava.cfx.ws.HelloWorld;
import org.fkjava.cfx.ws.impl.HelloWorldWs;
/**
* @author Kevin 发布Web Services
*/
public class ServerMain {
/**
* 发布Web Services
*
* @param args
* @throws FileNotFoundException
*/
public static void main(String[] args) throws FileNotFoundException {
// 创建CXF工厂,此工厂可以发布Web Services
JaxWsServerFactoryBean jaxWsServerFactoryBean = new JaxWsServerFactoryBean();
// 设置Web Services组件的接口
jaxWsServerFactoryBean.setServiceClass(HelloWorld.class);
// 设置Web Services的地址
jaxWsServerFactoryBean.setAddress("http://192.168.1.3:9999/HelloWorld");
// 设置Web Services组件的实现类
HelloWorldWs helloWorldWs = new HelloWorldWs();
jaxWsServerFactoryBean.setServiceBean(helloWorldWs);
// 添加服务器的In拦截器,把input soap消息打印到控制台
jaxWsServerFactoryBean.getInInterceptors().add(new LoggingInInterceptor());
// 添加服务器Out拦截器,把output soap消息打印到控制台
jaxWsServerFactoryBean.getOutInterceptors().add(new LoggingOutInterceptor());
// 发布Web Services
jaxWsServerFactoryBean.create();
System.out.println("HelloWorld Web Serviecs暴露成功!");
}
}
这种发布方式,生的成WSDL只有一部分,即是接口和实现都在一个XML文档中,这跟之前的发布方式生成的WSDL是不一样的,所以修改了发布方式后,一定要注意
重新执行wsdl2java,生成相应的代码