Blaze Ds 셋팅하기
Project 셋팅 한다
Project name : BlazeDS_Hello
Use default location : 체크
Application type
Web application(runs in Flash Player) : 체크
Server technology
Application server type : J2EE 설정
Use remote object access service : 체크
LiveCylce Data Service : 체크
Create Combined Java/Flex project using WTP : 체크
Java Source folder : src
Flex_WAR file 는 blazeds.war가 있는 폴더를 찾아서 war파일을 클릭해주면 된다~
그리고 next 를 눌러준다..
그러면 무사히 프로젝트가 생성이된다..
그리고 마지막
Context root 가 처음에는 webcontents 로 되어 있는데 이것을 /프로젝트네임 으로 바꿔준다..
그래야 실행이 된다...
중요..
그리고 테스트~~
BlazeDS_Hello/src/test 에 JAVA 파일 생성
package test;
public class Test {
public String getStr(){
return "Welcome BlazeDS 성공!";
}
}
WebContent/WEB-INF/flex/remote-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>
<!-- 이부분이 추가 되었습니다 -->
<destination id="blaze">
<properties>
<source>test.Test</source>
</properties>
</destination>
</service>
BlazeDS_Hello.mxml 파일 수정
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:RemoteObject id="ro" destination="blaze" fault="faultHandler(event)">
<mx:method name="getStr" result="resultHandler(event)"/>
</mx:RemoteObject>
<mx:Script>
<![CDATA[
import mx.rpc.remoting.mxml.RemoteObject;
import mx.controls.Alert;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
/**
* 에러가 났을 경우 이벤트 발생
* */
private function faultHandler(event:FaultEvent):void{
Alert.show(event.message.toString());
}
/**
* 제대로 실행 되었을 경우 이벤트 발생
* */
private function resultHandler(event:ResultEvent):void{
Alert.show(event.result.toString());
}
/**
* 버튼 클릭 후 RemoteObject Call
* */
private function remote_object_call():void{
// remoteObjecc에서 java method call
ro.getStr();
}
]]>
</mx:Script>
<mx:Button label="서비스 시작" click="remote_object_call()"/>
이렇게 하고 실행하면 성공 할것이다..
위의 소스밑 실행 순서의 참고는 장윤석 씨에게 저작권이 있는거 같다..
아무튼 참고 잘했습니다.~