flex+blazeds httpService,remotingObject

<?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>
 

 

 

 

你可能感兴趣的:(xml,Flex,UP,Adobe,Nokia)