flex调用Remoting失败。
错误信息如下:
(mx.messaging.messages::ErrorMessage)#0
? body = (Object)#1
? clientId = (null)
? correlationId = "2D787902-7186-D6A1-F049-8F739CC79C67"
? destination = ""
? extendedData = (null)
? faultCode = "Client.Error.MessageSend"
? faultDetail = "Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Status 404: url: 'http://localhost:8080/WebContent/messagebroker/amf'"
? faultString = "Send failed"
? headers = (Object)#2
? messageId = "5D03A245-E531-FE7F-FFDE-8F739D255904"
? rootCause = (mx.messaging.events::ChannelFaultEvent)#3
??? bubbles = false
??? cancelable = false
??? channel = (mx.messaging.channels::AMFChannel)#4
????? authenticated = false
????? channelSets = (Array)#5
??????? [0] (mx.messaging::ChannelSet)#6
????????? authenticated = false
????????? channelIds = (Array)#7
??????????? [0] "my-amf"
????????? channels = (Array)#8
??????????? [0] (mx.messaging.channels::AMFChannel)#4
????????? clustered = false
????????? connected = false
????????? currentChannel = (mx.messaging.channels::AMFChannel)#4
????????? initialDestinationId = (null)
????????? messageAgents = (Array)#9
??????????? [0] (mx.rpc::AsyncRequest)#10
????????????? authenticated = false
????????????? autoConnect = true
????????????? channelSet = (mx.messaging::ChannelSet)#6
????????????? clientId = (null)
????????????? connected = false
????????????? defaultHeaders = (null)
????????????? destination = "HelloRemoting"
????????????? id = "EB72B9FC-D54E-D29C-DB69-8F736DF76188"
????????????? reconnectAttempts = 0
????????????? reconnectInterval = 0
????????????? requestTimeout = -1
????????????? subtopic = ""
????? connected = false
????? connectTimeout = -1
????? enableSmallMessages = true
????? endpoint = "http://localhost:8080/WebContent/messagebroker/amf"
????? failoverURIs = (Array)#11
????? id = "my-amf"
????? mpiEnabled = false
????? netConnection = (flash.net::NetConnection)#12
??????? client = (mx.messaging.channels::AMFChannel)#4
??????? connected = false
??????? objectEncoding = 3
??????? proxyType = "none"
??????? uri = "http://localhost:8080/WebContent/messagebroker/amf"
????? piggybackingEnabled = false
????? polling = false
????? pollingEnabled = false
????? pollingInterval = 3000
????? protocol = "http"
????? reconnecting = false
????? recordMessageSizes = false
????? recordMessageTimes = false
????? requestTimeout = -1
????? uri = "http://{server.name}:{server.port}/WebContent/messagebroker/amf"
????? url = "http://{server.name}:{server.port}/WebContent/messagebroker/amf"
????? useSmallMessages = false
??? channelId = "my-amf"
??? connected = false
??? currentTarget = (mx.messaging.channels::AMFChannel)#4
??? eventPhase = 2
??? faultCode = "Channel.Connect.Failed"
??? faultDetail = "NetConnection.Call.Failed: HTTP: Status 404: url: 'http://localhost:8080/WebContent/messagebroker/amf'"
??? faultString = "error"
??? reconnecting = false
??? rejected = false
??? rootCause = (Object)#13
????? code = "NetConnection.Call.Failed"
????? description = "HTTP: Status 404"
????? details = "http://localhost:8080/WebContent/messagebroker/amf"
????? level = "error"
??? target = (mx.messaging.channels::AMFChannel)#4
??? type = "channelFault"
? timestamp = 0
? timeToLive = 0
或错误信息:
faultCode:Client.Error.MessageSend faultString:'Send failed' faultDetail:'Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Status 404: url: 'http://localhost:8080/WebContent/messagebroker/amf''
?
解决办法:
endpoint的问题,在services-config.xml文件中,由于此类型的endpoint:
<endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/>,中的{context.root}获取不到项目名称。
解决方法,选择项目,右键“Properties”-->“Flex Server”-->将Context root(浏览器访问时的上下文路径)的内容改为“/项目名称”,-->OK。