1、 JaxWsProxyFactoryBean 简介: 调用方式采用了和RMI类似的机制,即客户端直接服务器端提供的服务接口(interface),CXF通过运行时代理生成远程服务的代理对象,在客户端完成对webservice的访
- public class Client {
- public static void main(String[] args) {
- JaxWsProxyFactoryBean bean = new JaxWsProxyFactoryBean();
- bean.setServiceClass(HelloWorldService.class);
- bean.setAddress("http://localhost:9090/helloWorldService");
- HelloWorldService helloWorldService = (HelloWorldService)bean.create();
- String result = helloWorldService.sayHello("Kevin");
- System.out.println(result);
- }
-
- public class Client3 {
- public static void main(String[] args) throws Exception {
- JaxWsDynamicClientFactory clientFactory = JaxWsDynamicClientFactory.newInstance();
- Client client = clientFactory.createClient("http://localhost:9090/helloWorldService?wsdl");
- Object[] result = client.invoke("sayHello", "KEVIN");
- System.out.println(result[0]);
- }
- }
3、JaxWsServerFactoryBean
用JaxWsServerFactoryBean发布,需要独立的jetty包。
原文地址:http://blog.csdn.net/woshishabiaaaaa/article/details/24868323