Flex and Java Communication Framework to build the steps:
1. Create a new Web project and start Tomcat run to check that everything is ok (required);
2. Import the required jar pack (which I have given), Copy and paste the four XML resource files you want: Messaging-config.xml,proxy-config.xml,remoting-config.xml,services-config.xml to the Web-inf folder of your project, as shown in the following illustration:
3. Modify the Web.xml file: Paste the following content into the Web.xml, do not need to make any changes;
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/*
4. Add Flex project support and publish the Web project (required), as shown in the following figure:
----↓↓
Note: must follow the above diagram to do, otherwise it is difficult to configure the success!
5. New class Firstflex in this project
public class Firstflex {
public string Hello (string name) {
Return "Hello!" + name;
}
}
6. and add the following code to the Remoting-config.xml: Configure the class
Com.alex.flex.FirstFlex
7. Modify Flex-compiled version, or you cannot generate SWF. (Project Right click, select Properties)
8. Invoke Java processing class in Mxml
Import mx.rpc.events.ResultEvent;
function Rest (event:resultevent): void {
Rest_ta.text = Event.result as String;
}
function Remotingsayhello (): void {
H.hello (Inp.text);
}
]]>
Exposed objects
9. When the server is started, the project will automatically publish the Flex directory and SWF to WebApps.
10. Hey, you can see, simple flex and Java communication has been successful!