1.Flex端
(1)
encoding="utf-8"?>
layout="absolute"
viewSourceURL="srcview/index.html">
import
mx.controls.Alert;
import
mx.rpc.events.ResultEvent;
function
gg(evnet:ResultEvent):void{
var ff:String = evnet.result as
String;
ggg.text = ff;
}
function
remotingSayHello():void{
var sname:String =
nameInput.text;
h.sayHello(sname);
}
]]>
destination="hello" id="h"
result="gg(event)"
fault="mx.controls.Alert.show(event.fault.message)"
>
id="ggg" x="109" y="122"/>
label="say hello" click="remotingSayHello();" x="144"
y="193"/>
id="nameInput" x="109" y="73"/>
text="name" x="47" y="75"/>
(2)proxy-config.xml
encoding="UTF-8"?>
class="flex.messaging.services.HTTPProxyService">
100
2
true
class="flex.messaging.services.http.HTTPProxyAdapter"
default="true"/>
class="flex.messaging.services.http.SOAPProxyAdapter"/>
(3)remoting-config.xml
encoding="UTF-8"?>
class="flex.messaging.services.RemotingService">
class="flex.messaging.services.remoting.adapters.JavaAdapter"
default="true"/>
id="hello">
(4)services-config.xml
encoding="UTF-8"?>
/>
/>
class="flex.messaging.security.TomcatLoginCommand"
server="Tomcat"/>
class="mx.messaging.channels.AMFChannel">
class="flex.messaging.endpoints.AMFEndpoint"/>
(5)编译断加上:-locale en_US -services services-config.xml
2.Java端
(1)Java_FlexTest.java
package com.protel;
public class HelloWorld {
public String sayHello(String str){
System.out.println("ni da
ye:"+str);
return "kenny say "+str;
}}
(2)proxy-config.xml
encoding="UTF-8"?>
class="flex.messaging.services.HTTPProxyService">
100
2
true
class="flex.messaging.services.http.HTTPProxyAdapter"
default="true"/>
class="flex.messaging.services.http.SOAPProxyAdapter"/>
(3)remoting-config.xml
encoding="UTF-8"?>
class="flex.messaging.services.RemotingService">
class="flex.messaging.services.remoting.adapters.JavaAdapter"
default="true"/>
id="hello">
com.protel.HelloWorld
(4)services-config.xml
encoding="UTF-8"?>
/>
/>
class="flex.messaging.security.TomcatLoginCommand"
server="Tomcat"/>
class="mx.messaging.channels.AMFChannel">
class="flex.messaging.endpoints.AMFEndpoint"/>
class="mx.messaging.channels.SecureAMFChannel">
class="flex.messaging.endpoints.SecureAMFEndpoint"/>
false
class="mx.messaging.channels.AMFChannel">
class="flex.messaging.endpoints.AMFEndpoint"/>
true
4
level="Error">
[BlazeDS]
false
false
false
false
Endpoint.*
Service.*
Configuration
false
(5)web.xml
encoding="UTF-8"?>
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
flex.class.path
/WEB-INF/flex/hotfixes,/WEB-INF/flex/jars
flex.messaging.HttpFlexSession
MessageBrokerServlet
flex.messaging.MessageBrokerServlet
services.configuration.file
/WEB-INF/flex/services-config.xml
1
MessageBrokerServlet
/messagebroker/*
index.jsp