您的位置:首页 > 其它

Xfire发布webservice无配置demo

2011-11-28 23:09 323 查看
步骤:

一、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);

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: