[RPC Fault faultString="Send failed" faultCode="Client.Error.MessageSend" faultDetail="Channel.Connect.Failed error NetC

[RPC Fault faultString="Send failed"faultCode="Client.Error.MessageSend"faultDetail="Channel.Connect.Failed error NetConnection.Call.Failed:HTTP: Status 404:
url: 'http://localhost:8080/WebRoot/messagebroker/amf'"]

当我看到url时发现工程名是'FirstFlex',但信息提示成了WebRoot,故在工程属性对话框-->Flex Server中的
Root   Url    -->http://localhost:8080/FirstFlex
Context Root-->WebRoot 故把WebRoot改成'FirstFlex',重新编译运行即可。
原因是myeclipse没有把用户某些设置更新过去。

学学Flex与Java的交互:

(1)创建Java文件。点击src文件夹,然后创建java class.类的包为hello,名字为HelloWorld.
package hello;
 public class HelloWorld {
public String sayHelloTo(String str) {
System.out.println("Hello " + str);    
     return "Hello " + str; }    
}
(2)在FirstFlex.mxml文件中新建一个text和一个按钮,来显示从HelloWorld传回来的信息。
<?xml version="1.0" encoding="utf-8"?>
 <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
 <mx:Script>
  <![CDATA[ import mx.rpc.events.FaultEvent;
    import mx.rpc.events.ResultEvent;
       [Bindable]
       private var helloResult:String;
       private function sayHelloTo():void {
         ro.sayHelloTo(inputText.text);
         }
        private function resultHandler(event:ResultEvent):void {
           helloResult = event.result as String;
              } ]]> </mx:Script>
         <mx:RemoteObject id="ro" destination="helloworld" result="resultHandler(event)" />
          <mx:HBox width="100%">
            <mx:TextInput id="inputText"/>
            <mx:Button label="Submit" click="sayHelloTo()"/>
         </mx:HBox>
        <mx:Label text="{helloResult}"  x="10" y="30"/>
     </mx:Application>

(3)现在,我们要定义remote object,让flex程序能够调用java类。首先来配置/WEB-INF/flex/remoting-config.xml文件,添加以下粗体部分来新增一个destionation—HelloWorld类。
<?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>hello.HelloWorld</source>
        </properties>
  </destination>
</service>

(4)到此,配置结束。然后选择此项目,选择在服务器上执行。即浏览地址为:http://localhost:8080/FirstFlex/FirstFlex.html如果你能在输入框输入字段之后,点击按钮能返回Hello,XXX的信息,就代表成功了。
原文地址:https://www.cnblogs.com/frostbelt/p/1815201.html