ITeye博客

第一次 cxf

lmning · 2009-04-16 15:23 · webservice · Markdown

 
 
到apache 下载cxf需要的包,最好jdk6.0免得出错
public class WebserviceServer {

	public WebserviceServer(){
		HelloServiceImpl hello = new HelloServiceImpl();
		ServerFactoryBean factory = new ServerFactoryBean();
		factory.setServiceClass(IHelloService.class);
		factory.setAddress("http://127.0.0.1:9000/Hello");
		factory.setServiceBean(hello);
		factory.create();
	}
	public static void main(String[] args) throws InterruptedException {
		new WebserviceServer();
		System.out.println("server starting......");
		Thread.sleep(60*1000);
		System.out.println("server exit");
		System.exit(0);
		
	}

 

 

启动server

 

浏览器查看:

http://127.0.0.1:9000/Hello?WSDL

 

调用webservice

 

public class Client {

	
	public static void main(String[] args) {
		ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
		factory.setServiceClass(IHelloService.class);
		factory.setAddress("http://127.0.0.1:9000/Hello");
		IHelloService hello = (IHelloService) factory.create();
		System.out.println(hello.sayHello("hello lmning"));

	}

}

  

 

ok!

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。