How to Interact Flex with Java

Links to the original text:
Three flex4 andJava The way to communicate smoothly is:
flex communicates with ordinary java class RemoteObject;
Fl interacts with server HTTPService;
Flexible interacts with web service.
When you try to use flex to communicate with ordinary java classes, you usually use RemoteObject. The specific code snippets are as follows:
  package com.flex.demo;
*The first function description: this class is used to implement flex communication with methods in common java classes
* @author Administrator
//The above is a functional description of the head, you can not write.
<!--flex And ordinary java Class communication-->
<s:RemoteObject id="serv" destination="myservice" fault="serv_faultHandler(event)" result="serv_resultHandler(event)">
[js] view plaincopy
<!--flex Interacting with the server HTTPService-->
<!--servlet Code-->
* The second function description: The servlet is used to interact with flex
* @author Administrator
public class SimpleServiceServlet extends HttpServlet {
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.getWriter().write("I'm a server.“);
Fl interacts with server HTTPService, flex-side code
<!-- flex Interacting with the server-->
<s:HTTPService id="service" fault="service_faultHandler(event)" result="service_resultHandler(event)"   url="http://localhost:8080/flexdemo/simpleServiceServlet">
<!--Third kinds flex And webservice interactive WebService-->
<!--flex And webservice Interactive call here for a weather forecast webservice-->
<s:WebService id="ws"
<!-- call webservice Method<speration>-->
In addition, I would like to say that although the code segment for pop-up boxes is very simple, it is better not to omit them:
protected function service_faultHandler(event:FaultEvent):void{"The call failed:"+event.fault.message as String,"Prompt ");
protected function service_resultHandler(event:ResultEvent):void{"The call succeeded:"+event.result as String,"Prompt ");
<span style="font-family:Arial; background-color:#ffffff"></span>

Reproduced in:

Keywords: Java

Added by y.t. on Tue, 08 Oct 2019 11:18:28 +0300