如题所述
1、cfx调用webservice时需要加载
cxf-2.2.10.jar
jetty-6.1.21.jar
jetty-util-6.1.21.jar
servlet-2_5-api.jar
wsdl4j-1.6.2.jar
XmlSchema-1.4.5.jar
这些包。
服务端代码代码如下:
Server impl=new Server();
JaxWsServerFactoryBean factoryBean=new JaxWsServerFactoryBean();
factoryBean.setAddress("http://ip地址/hello");
factoryBean.setServiceClass(HelloWorldServiceInf.class);
factoryBean.setServiceBean(impl);
factoryBean.getInInterceptors().add(new LoggingInInterceptor());
factoryBean.getOutInterceptors().add(new LoggingOutInterceptor());
factoryBean.create();
客户端代码
JaxWsProxyFactoryBean factoryBean=new JaxWsProxyFactoryBean();
factoryBean.getInInterceptors().add(new LoggingInInterceptor());
factoryBean.getOutInterceptors().add(new LoggingOutInterceptor());
factoryBean.setServiceClass(HelloWorldServiceInf.class);
factoryBean.setAddress("http://***/hello");
HelloWorldServiceInf impl=(HelloWorldServiceInf) factoryBean.create();
System.out.println(impl.sayHello("hello"));
cxf-2.2.10.jar
jetty-6.1.21.jar
jetty-util-6.1.21.jar
servlet-2_5-api.jar
wsdl4j-1.6.2.jar
XmlSchema-1.4.5.jar
这些包。
服务端代码代码如下:
Server impl=new Server();
JaxWsServerFactoryBean factoryBean=new JaxWsServerFactoryBean();
factoryBean.setAddress("http://ip地址/hello");
factoryBean.setServiceClass(HelloWorldServiceInf.class);
factoryBean.setServiceBean(impl);
factoryBean.getInInterceptors().add(new LoggingInInterceptor());
factoryBean.getOutInterceptors().add(new LoggingOutInterceptor());
factoryBean.create();
客户端代码
JaxWsProxyFactoryBean factoryBean=new JaxWsProxyFactoryBean();
factoryBean.getInInterceptors().add(new LoggingInInterceptor());
factoryBean.getOutInterceptors().add(new LoggingOutInterceptor());
factoryBean.setServiceClass(HelloWorldServiceInf.class);
factoryBean.setAddress("http://***/hello");
HelloWorldServiceInf impl=(HelloWorldServiceInf) factoryBean.create();
System.out.println(impl.sayHello("hello"));
温馨提示:答案为网友推荐,仅供参考