如何解决xfire调用cxf的webservice问题
1个回答
展开全部
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"));
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询