服务端发布Web Services:
/**
*
*/
package lee;
import java.io.FileNotFoundException;
import javax.xml.ws.Endpoint;
import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.jaxws.EndpointImpl;
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 {
// Web Servers的对象
HelloWorld helloWorld = new HelloWorldWs();
// 发布Web Services
// publish第一个参数指定Web Services的地址,并指定它的名字
// publish第二个参数指定服务的提供者,即Web Servers的对象
// 在服务端增加拦截器
EndpointImpl endpointImpl = (EndpointImpl) Endpoint.publish(
"https://192.168.1.3:9999/HelloWorld", helloWorld);
// 添加服务器的In拦截器,把input soap消息打印到控制台
endpointImpl.getInInterceptors().add(new LoggingInInterceptor());
// 添加服务器Out拦截器,把output soap消息打印到控制台
endpointImpl.getOutInterceptors().add(new LoggingOutInterceptor());
System.out.println("HelloWorld Web Serviecs暴露成功!");
}
}
/**
*
*/