`

flex+blazeds httpService,remotingObject

    博客分类:
  • flex
阅读更多
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
	<![CDATA[
		import mx.rpc.events.ResultEvent;
		import mx.controls.Alert;
	   private function callRO():void{
                   
                        firstRO.doSome(1000,200);
                        firstRO.addEventListener(ResultEvent.RESULT,getROResult);
                
                }
                private function getROResult(e:ResultEvent):void{
                    Alert.show(e.result.toString(),"远程对象访问"); 
                    //注意下边必须有endpoint<RemotingObject>标签
                }
            ]]>
        </mx:Script>
        <mx:RemoteObject id="firstRO" destination="hello" endpoint="http://localhost:8400/flex_java/messagebroker/amf" />
        <mx:Label id="lbl" text="请输入姓名:"  x="29" y="49" />
        <mx:Button id="btn" click="callRO()" label="RO请求"  x="307" y="50" />
</mx:Application>

 

package com;

public class Hello {

		public double doSome(int a,int b){
			return a+b;
		}
}

 

<destination id="hello">
		<properties>
			<source>
				com.Hello
			</source>
		</properties>
</destination>

  HttpService

 

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
	<mx:HTTPService destination="product" id="service" useProxy="false" url="http://localhost:8400/flex_java/product.xml">
		
	</mx:HTTPService>
	<mx:Script>
		<![CDATA[
			import mx.rpc.events.FaultEvent;
			import mx.rpc.events.ResultEvent;
			
			public function init():void{
				service.send();
				service.addEventListener(ResultEvent.RESULT,result);
				service.addEventListener(FaultEvent.FAULT,error);
			}
			public function result(e:ResultEvent){
				trace("success");
				trace(service.lastResult.product.name);
				trace(service.lastResult.product.description);
			}
			public function error(e:FaultEvent){
//				trace(e.message);
				trace(e.statusCode);
				trace(e.fault.faultDetail);
			}
		]]>
	</mx:Script>
	<mx:DataGrid dataProvider="{service.lastResult.product}" width="100%" height="100%"/>
</mx:Application>

 

 <?xml version="1.0" encoding="utf-8" ?> 
- <product productId="3">
  <name>Nokia 3100 Pink</name> 
  <description>Light up the night with a glow-in-the-dark cover - when it is charged with light you can easily find your phone in the dark. When you get a call, the Nokia 3100 phone flashes in tune with your ringing tone. And when you snap on a Nokia Xpress-on gaming cover, you will get luminescent light effects in time to the gaming action.</description> 
  <price>139.0</price> 
  <image>Nokia_3100_pink.gif</image> 
  <category>3000</category> 
  <qtyInStock>30</qtyInStock> 
  </product>
 

 

 

 

分享到:
评论

相关推荐

    Flex4+Spring+ibatis实战系列教程

    BlazeDS 提供了 ChannelSet、MessageBroker 等组件,使得 Flex 可以通过 Topic(发布/订阅)或 Remoting(远程方法调用)的方式与服务器通信。 对于 Spring 框架,它是一个轻量级的、全面的 Java 应用开发框架,...

    Flex 连接后台Java的几种方法选择

    RemotingObject 技术是 Blazeds 的核心,能够直接远程调用 Java 后台提供的公共接口,使其效率大大提升,一般是采用 HTTPService 方式的 10 倍左右。 LiveCycle Data Services LiveCycle Data Services 是一个功能...

    Communicating between Flex and .NET

    6. **JSON(JavaScript Object Notation)**:另一种轻量级的数据交换格式,虽然不是Flex原生支持的,但通过库如AS3CoreLib,可以在Flex中解析和生成JSON数据,与C#服务进行通信。 7. **安全性**:跨域策略文件...

    Flex与JAVA的结合使用

    4. **Java Remoting**:Flex可以通过Java Remote Method Invocation (Java RMI) 或 HTTP-based Remote Object (RO) 与Java应用进行通信。RO是BlazeDS提供的一种轻量级远程调用机制,它通过HTTP协议实现Flex与Java...

    基于flex的web应用系统开发探索doc.doc.pdf

    通过BlazeDS,开发者可以连接Flex客户端和Java后端服务,如使用Spring和Hibernate框架的应用程序,实现远程对象调用(Remote Object)和HTTP服务(HttpService)等功能。 远程对象调用(RemoteObject)是一种在Flex...

    flex前台和后台交互例子

    Flex SDK内置了Flash Remoting模块,可以轻松实现AMF通信。 2. ** BlazeDS与LiveCycle Data Services** Adobe提供了BlazeDS和LiveCycle Data Services这两个中间件,用于在Flex与Java服务器之间建立AMF连接。...

    Flex与.Net互操作

    Adobe的BlazeDS或LCDS(LiveCycle Data Services)提供了对AMF的支持,使得Flex能够直接与.NET的.NET Remoting或WCF服务进行高速通信。 3. 直连HTTP服务:Flex可以直接通过HTTP请求与.NET的HTTP服务接口交互,例如...

Global site tag (gtag.js) - Google Analytics