使用xfire常用方式远程服务类访问 package cn.com.huawei.spring.xfire.ws.client; import java.net.MalformedURLException; import org.codehaus.xfire.client.XFireProxyFactory; import org.codehaus.xfire.service.Service; import org.codehaus.xfire.service.binding.ObjectServiceFactory; import cn.com.huawei.spring.xfire.ws.service.IHelloSerivce; /** * 常用的服务代理类 * @author sz0189 * */ public class HelloSeriviceClient { public static void main(String[] args) { String serviceURL = "http://127.0.0.1:8080/XFireSpring/services/IHelloSerivce"; //通过远程服务工厂创建服务类 Service serviceModel = new ObjectServiceFactory() .create(IHelloSerivce.class); //创建xfire的代理工厂 XFireProxyFactory serviceFactory = new XFireProxyFactory(); IHelloSerivce service; try { //将客户端的存根转换为本地ws的服务的类 service = (IHelloSerivce) serviceFactory.create( (org.codehaus.xfire.service.Service) serviceModel, serviceURL); //执行服务代理 String msg = service.hello("xiaobai"); System.out.println("Mesage = " + msg); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
spring和xfire整合的应用开发的原理和客户端开发方式(二)
最新推荐文章于 2024-05-31 22:15:00 发布