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

OSGI-flex-blazeds通信

发布时间:2020-12-15 01:10:45 所属栏目:百科 来源:网络整理
导读:1.发布服务 DictionaryString,String initparams = new HashtableString,String(); initparams.put("services.configuration.file","D:/javatools/factoryspaces/loowj.base/WEB-INF/flex/services-config.xml"); initparams.put("load-on-startup","1"); Se
1.发布服务
Dictionary<String,String> initparams = new Hashtable<String,String>();
 initparams.put("services.configuration.file","D:/javatools/factoryspaces/loowj.base/WEB-INF/flex/services-config.xml");
 initparams.put("load-on-startup","1");
 
 ServiceReference httpServiceRef = context.getServiceReference(HttpService.class.getName());
 httpService = (HttpService) context.getService(httpServiceRef);
 // 直接发布
 try {
 httpService.registerServlet("/messagebroker",new MessageBrokerServlet(),initparams,null);
 } catch (ServletException e) {
 e.printStackTrace();
 } catch (NamespaceException e) {
 e.printStackTrace();
 }

2.XML调用
<mx:Button click="submit()" label="hello" horizontalCenter="0" verticalCenter="0"/>  

public function submit():void{  
	           var remote:RemoteObject = new RemoteObject();  
	           //监听调用成功事件  
	           remote.addEventListener(ResultEvent.RESULT,result);                  
	           //监听失败事件  
	           remote.addEventListener(FaultEvent.FAULT,fault);    
	           //调用在J2EE端remoting-config.xml中配置的暴露出的类的名称 id  
	           remote.destination = "hello";  
	           remote.endpoint = "http://{server.name}:{server.port}/messagebroker/amf/";
	           //调用J2EE端类中的方法  
	           var operation:AbstractOperation=remote.getOperation("hello");  
	           operation.arguments=['loow'];
				operation.send();	
	       }  
	         
	       private function result(evt:ResultEvent):void{  
	           Alert.show(evt.result.toString());  
	       }  
	        private function fault(evt:FaultEvent):void{  
	        	trace(evt.message);
	           Alert.show("调用失败!");  
	       }

3. 启动?
进入propertyies-->Flex Build Path -->Output folder URL --> 配置为访问的地址如:http://localhost:8888
Debug Configurations-->URL ro path to launch 将会变为 http://localhost:8888

(编辑:李大同)

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

    推荐文章
      热点阅读