Flex + LCDS + J2EE Web 项目(2) Hello World

5 篇文章 0 订阅
4 篇文章 0 订阅
[color=blue]请关注新浪微博 账号:屌丝开发控([url]http://weibo.com/u/3356934744[/url])[/color]

首先要搭建好开发环境,并且已经能发布、运行Web项目了
如果还没有,参见[url]http://quasimodo-es.iteye.com/admin/blogs/499584[/url]

配置Hello World

如新建的项目名为 TestLCDS

1、TestLCDS.mxml


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

<mx:RemoteObject id="MyRO" destination="HelloWorldRO"/>


<mx:Script>
<![CDATA[
private function onClick() : void{
MyRO.sayHello(" java ");
}
]]>
</mx:Script>

<mx:Button x="220" y="91" label="hello java" click="onClick()"/>

</mx:Application>


2、WebRoot/WEB-INF/flex/remoting-config.xml



<?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>

<!-- destinations -->
<destination id="HelloWorldRO">
<properties>
<source>com.Hello</source> <!-- Java类 -->
</properties>
</destination>


</service>



3、


package com;
public class Hello {

// 方法必须是public
public void sayHello(String str){
System.out.println(" hello world , and hello " + str);
}

}





运行项目,点击" hello java"Button ,在控制台就可以看到
打印出的
hello world , and hello java

分析一下控制台的输出,可以看到Flex和J2EE是怎么通信的:

[LCDS]Channel endpoint my-amf received request.
[LCDS]Deserializing AMF/HTTP request
Version: 3
(Message #0 targetURI=null, responseURI=/2)
(Array #0)
[0] = (Typed Object #0 'flex.messaging.messages.RemotingMessage')
operation = "sayHello"
source = null
body = (Array #1)
[0] = " java "
messageId = "7DB329E0-34BE-658E-5D84-82242C0DDD0A"
clientId = "21AEFB2F-101E-8EC5-A34B-86785A7ED457"
timeToLive = 0
timestamp = 0
destination = "HelloWorldRO"
headers = (Object #2)
DSId = "nil"
DSEndpoint = "my-amf"

hello world , and hello java
[LCDS]Adapter 'java-object' called 'com.Hello.sayHello(java.util.Arrays$ArrayList (Collection size:1)
[0] = java
)'
[LCDS]Result: 'null'
[LCDS]Serializing AMF/HTTP response
Version: 3
(Message #0 targetURI=/2/onResult, responseURI=)
(Externalizable Object #0 'DSK')
1.256313859132E12
(Byte Array #1, Length 16)
(Byte Array #2, Length 16)
(Byte Array #3, Length 16)


如果项目不能和J2EE通信,控制台没有显示通信信息,重新配置Flex Build path 和 Flex Server参数
[url]http://quasimodo-es.iteye.com/blog/486739[/url]
建议使用方法2


Flex 和 J2EE之间信息交互:Object 、 array ==
[url]http://quasimodo-es.iteye.com/blog/503830[/url]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值