加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Xfire发布webservice无配置demo

发布时间:2020-12-17 01:08:23 所属栏目:安全 来源:网络整理
导读:步骤: 一、Create an ObjectServiceFactory 二、Register the bean 三、Expose xfire public void init(ServletConfig config) throws ServletException {System.out.println("init service");/**?Create an ObjectServiceFactory?Register the bean?Expose

步骤:

一、Create an ObjectServiceFactory

二、Register the bean

三、Expose xfire


	public void init(ServletConfig config) throws ServletException {
		System.out.println("init service");
		
		/**
			?Create an ObjectServiceFactory
			?Register the bean
			?Expose xfire
		 * */
		//first we create a XFire instance,using the default implementation
		//you can register your own implementation via XFireFactory.registerFactory()
		XFire xfire = XFireFactory.newInstance().getXFire();
		//the default transport manager handles a number of transport mechanisms,//which is good enough for our needs
		ServiceFactory factory = new ObjectServiceFactory(xfire.getTransportManager());
		//note that we'd like to specify our own service name,so we use the overloaded
		//create method instead of the simpler one that just takes in a class name
		Service service = factory.create(serviceimpl.class,"hi",null,null);
		//if Hello.class is an interface,then we need to specify the implementation class
		service.setProperty(ObjectInvoker.SERVICE_IMPL_CLASS,serviceimpl.class);
		ServiceInfo sinfo = service.getServiceInfo();
		sinfo.removeOperation("setTest");
		Service ss = sinfo.getService();
		
		controller = new XFireServletController(xfire,config.getServletContext());
		controller.getServiceRegistry().register(ss);

	}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读