1. Server代码 package com.east.flex.demo; import com.east.flex.Person; public class HelloWorld { public Person sayHello(String str) { Person p = new Person(); p.setId(2222222); p.setName("East"); p.setSex("man"); return p; } } package com.east.flex; public class Person { private long id; private String name; private String sex; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getSex() { return sex; } public void setSex(String sex) { this.sex = sex; } public long getId() { return id; } public void setId(long id) { this.id = id; } } 2.Client 代码 package com.east.flex { [RemoteClass(alias="com.east.flex.Person")] public class Person { public var id:Number; public var name:String; public var sex:String; public function Person() { } public function toStrings():String { trace("start Person"); return "ID :"+id+"Name :"+name+"Sex :"+sex; } } } <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Script>import com.east.flex.Person</mx:Script> <mx:Script> <!--[CDATA[ import mx.controls.Alert; import mx.rpc.events.ResultEvent; [Bindable] private var showInfo:Person; private function callJava():void { helloService.sayHello(input.text); } private function showResult(event:ResultEvent):void { trace(event.result.toString()); showInfo = event.result as Person; trace(showInfo.toStrings()); show.text=showInfo.id+"/n"+showInfo.name+"/n"+showInfo.sex; } ]]--> </mx:Script> <mx:Button x="347" y="72" label="Call Java" click="callJava()"/> <mx:TextInput id="input" x="156" y="72"/> <mx:TextArea x="156" y="102" width="430" height="236" id="show" fontSize="36"/> <mx:RemoteObject id="helloService" endpoint="http://localhost:8080/java2/messagebroker/amf" showBusyCursor="true" destination="helloWorld" result="showResult(event)"> </mx:RemoteObject> </mx:Application> 3.config file <?xml version="1.0" encoding="UTF-8"?> <service id="remoting-service" class="flex.messaging.services.RemotingService"> <adapters> <adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter" default="true"/> </adapters> <default-channels> <channel ref="my-amf"/> </default-channels> <destination id="helloWorld"> <properties> <source>com.east.flex.demo.HelloWorld</source> </properties> </destination> </service>