【问题标题】:AMF body dropped on DeserializationAMF 主体在反序列化时丢弃
【发布时间】:2011-03-24 23:14:17
【问题描述】:

我正在尝试通过 BlazeDS 对 ColdFusion 服务器进行简单的 Flex AMF 调用。使用 RemoteObject,我试图向服务器发送登录请求,并以成功或失败进行响应。出于某种原因,当数据到达 BlazeDS 时,消息的正文在反序列化期间被丢弃(我认为)。这是我的 ColdFusion/BlazeDS 日志代码以及 CFC 和 Flex ActionScript 调用。

我们不胜感激。谢谢!

[BlazeDS]Channel endpoint my-cfamf received request.
[BlazeDS]Deserializing AMF/HTTP request
Version: 3
  (Message #0 targetURI=null, responseURI=/3)
    (Array #0)
      [0] = (Typed Object #0 'flex.messaging.messages.RemotingMessage')
        source = "service.UserService"
        operation = "authenticateUser"
        destination = "ColdFusion"
        timestamp = 0
        headers = (Object #1)
          DSEndpoint = "my-cfamf"
          DSId = "883A97CF-4A08-0B8E-9056-1BF562A40EB4"
        body = (Array #2)
          [0] = "Username"
          [1] = "Password"
        clientId = null
        messageId = "D1743AB9-54B8-E73C-85C7-E990DE7F1ECE"
        timeToLive = 0

[BlazeDS]Before invoke service: remoting-service
  incomingMessage: Flex Message (flex.messaging.messages.RemotingMessage) 
    operation = authenticateUser
    clientId = 883AAF5D-900B-410A-1E8B-3B3FBD6552A6
    destination = ColdFusion
    messageId = D1743AB9-54B8-E73C-85C7-E990DE7F1ECE
    timestamp = 1300998708880
    timeToLive = 0
    body = null
    hdr(DSId) = 883A97CF-4A08-0B8E-9056-1BF562A40EB4
    hdr(DSEndpoint) = my-cfamf


-- Flex
            remoteUserService = new RemoteObject;
            remoteUserService.destination = "ColdFusion";
            remoteUserService.source = "service.UserService";
            remoteUserService.authenticateUser.addEventListener("result",  authenticate_requestComplete);
            remoteUserService.authenticateUser.addEventListener("fault",  authenticate_requestFailure);     
            remoteUserService.authenticateUser({username:username, password:password});

-- ColdFusion

    <cffunction name="authenticateUser" access="remote" returnType="Struct">
        <cfargument name="username" type="string">
        <cfargument name="password" type="string">


        <cfset ret = getAuthenticationService().authenticate(username, password) />

        <cfreturn ret>
    </cffunction>

【问题讨论】:

  • 它把这些参数变成了一个数组。这似乎不对。这些值也是大写的。那是您从 Flex 方面传递的内容吗? Flex 端的“用户名”对象是什么?只是一个字符串?
  • 请提供发送对象的 Flex 代码。
  • @James,是的,从 flex 传递的值只是两个字符串。对于我设置的测试,我只是为每个相应的字段发送了测试字符串“用户名”和“密码”。在 RemoteObject 参数中,用户名和密码只是字符串。我将它们放入一个对象中,因为这就是我被指示通过 RemoteObject 调用传递变量的方式。那有意义吗?感谢您的帮助!
  • @J_A_X 这是我发送对象的代码: ` public function authenticate(username:String, password:String):void { remoteUserService.authenticateUser({username:username, password:password}); } `
  • 数据以数组的形式进入服务器仍然很奇怪。尝试在具有这些属性的 ActionScript 中创建一个类型化的值对象,然后发送该对象而不是普通对象。

标签: apache-flex coldfusion blazeds amf livecycle


【解决方案1】:

为什么不将凭据作为两个字符串传递而不是创建一个对象?这样它们就会出现在 CF 的参数范围内。或者,您可以将其打包到数据传输对象中,但这似乎有点过头了。

【讨论】:

  • 与 Nic 合作后,我们发现我正在尝试使用 ColdSpring Singletons 与 flex 进行通信。这是不可能的,因为每个 HTTP 请求都会创建一个新的 CFC 实例。 Coldspring 不允许这样做,这就是 AMF 失败的原因。现在我有一个将请求传递给服务的 remoteProxy,一切正常。谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多