<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Wade Arnold &#187; Blaze DS</title>
	<atom:link href="http://wadearnold.com/blog/category/flash/blaze-ds/feed" rel="self" type="application/rss+xml" />
	<link>http://wadearnold.com/blog</link>
	<description>The spoils of the integration of PHP and ActionScript</description>
	<lastBuildDate>Thu, 04 Feb 2010 15:17:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>BlazeDS: Worth figuring out! HelloWorld Example</title>
		<link>http://wadearnold.com/blog/flash/blazeds-worth-figuring-out-helloworld-example</link>
		<comments>http://wadearnold.com/blog/flash/blazeds-worth-figuring-out-helloworld-example#comments</comments>
		<pubDate>Sun, 02 Mar 2008 20:00:39 +0000</pubDate>
		<dc:creator>wadearnold</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Blaze DS]]></category>
		<category><![CDATA[Flash Platform]]></category>

		<guid isPermaLink="false">http://wadearnold.com/blog/?p=11</guid>
		<description><![CDATA[I am working on a project for John Deere and they have a huge WebSphere implementation. The odds of transferring them over to AMFPHP are not very realistic! Anyways, I spent the weekend playing with BlazeDS as my endpoint for Flex and I really like it. I took me about six hours to figure out [...]]]></description>
			<content:encoded><![CDATA[<p>I am working on a project for <a href="http://www.johndeere.com" target="_blank">John Deere</a> and they have a huge <a href="http://www-306.ibm.com/software/websphere/" target="_blank">WebSphere </a>implementation. The odds of transferring them over to <a href="http://www.amfphp.org">AMFPHP </a>are not very realistic! Anyways, I spent the weekend playing with <a href="http://opensource.adobe.com/wiki/display/blazeds/BlazeDS" target="_blank">BlazeDS </a>as my endpoint for Flex and I really like it. I took me about six hours to figure out tomcat, java in eclipse, and the whole server side <a href="http://blog.ashier.com/2008/02/22/blazeds-remoting-a-helloworld-example/">endpoint </a>thing. From there it has only taken me about an hour to figure out class mapping, authentication, push technology, and connecting everything to hybernate. So to anyone looking into using <a href="http://opensource.adobe.com/wiki/display/blazeds/BlazeDS" target="_blank">BlazeDS </a>stick with it a bit. The biggest hurdle is probably java and tomcat for those like me that don&#8217;t understand why you need to restart the application server sometimes and other times it just works. Overall great job Adobe and thanks for releasing a quality opensource project.</p>
<p>The following is my simple hello world example that I used to get started with learning how this system works.</p>
<p>Here are all the files Zipped. I can not figure out how to do code highlighting. Suggestions~!</p>
<p><a href="http://wadearnold.com/blog/wp-content/uploads/2008/03/helloworld-blazeds.zip" title="helloworld-blazeds.zip">helloworld-blazeds.zip</a></p>
<p>Java Class File for remote service. Place compiled class in $tomcat_home/webapps/blazeds/WEB-INF/classes/HelloWorld.class</p>
<pre lang="java">
import java.util.Date;
public class HelloWorld {
	private String userSaid;
	public String repeat(String said) {
		this.userSaid = "Reply from server: " + said;
		return this.userSaid;
	}
	public String sayHello() {
		Date now = new Date();
		return "Hello World " + now;
	}
}</pre>
<p>Remoting-config.xml place in $tomcat_home/webapps/blazeds/WEB-INF/flex/remoting-config.xml</p>
<pre lang="xml">
<service id="remoting-service" class="flex.messaging.services.RemotingService">
    <adapters>
        <adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter" default="true"></adapter-definition>
    </adapters>
    <destination id="Hello">
<properties>
   			<source>HelloWorld</source>
   		</properties>
   </destination>
    <default-channels>
        <channel ref="my-amf">
    </channel>
</default-channels>
</service></pre>
<p>services-config.xml $tomcat_home/webapps/blazeds/WEB-INF/flex/services-config.xml</p>
<pre>
<services-config>
	<services>
		<service id="remoting-service" class="flex.messaging.services.RemotingService" messagetypes="flex.messaging.messages.RemotingMessage">
			<adapters>
	        	<adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter" default="true"></adapter-definition>
	    	</adapters>
	    	<destination id="Hello">
<properties>
	            	<source>HelloWorld</source>
		        </properties>
		        <channels>
					<channel ref="my-amf">
				</channel>
	    	</channels>
    	</destination>
	</service>
	<channels>
		<channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
			<endpoint uri="http://192.168.52.128:8080/blazeds/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint">
		</endpoint>
	</channel-definition>
</channels>
</services></services-config></pre>
<p>That&#8217;s it for the server side. Now you just need two files updated to run this from Flex.</p>
<pre lang="actionscript">

<mx:application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundcolor="#FFFFFF" viewsourceurl="srcview/index.html">
    <mx:remoteobject id="myservice" fault="faultHandler(event)" showbusycursor="true" destination="Hello">
        <mx:method name="sayHello" result="resultHandler(event)">
        <mx:method name="repeat" result="resultHandler(event)">
    </mx:method>

    <mx:script>
        <!--[CDATA[
            import mx.managers.CursorManager;
            import mx.rpc.events.ResultEvent;
            import mx.rpc.events.FaultEvent;
            private function faultHandler(fault:FaultEvent):void
            {
                CursorManager.removeBusyCursor();
                result_text.text = "code:n" + fault.fault.faultCode + "nnMessage:n" + fault.fault.faultString + "nnDetail:n" + fault.fault.faultDetail;
            }

            private function resultHandler(evt:ResultEvent):void
            {
                result_text.text = evt.message.body.toString(); // same as: evt.result.toString();
            }
        ]]-->
    </mx:script>

    <mx:button x="250" y="157" label="sayHello" width="79" click="myservice.getOperation('sayHello').send();">
    <mx:button x="250" y="187" label="Repeat" click="myservice.getOperation('repeat').send(myText.text); ">
    <mx:textarea x="10" y="36" width="319" height="113" id="result_text">
    <mx:label x="10" y="10" text="Result:">
    <mx:textinput x="82" y="187" id="myText" text="Sent to Server">
</mx:textinput>
</mx:label></mx:textarea></mx:button></mx:button></mx:method></mx:remoteobject></mx:application></pre>
<p>And then your services-config.xml file in your flex project. Note that this can be the same file as what is on the server! But it needs to be in both places.</p>
<pre lang="xml">

<service id="remoting-service">
    class="flex.messaging.services.RemotingService"&gt;

    <adapters>
        <adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter" default="true"></adapter-definition>
    </adapters>
    <destination id="Hello">
<properties>
   			<source>HelloWorld</source>
   		</properties>
   </destination>
    <default-channels>
        <channel ref="my-amf">
    </channel>

</default-channels>
</service></pre>
<p>That&#8217;s it! Now you have your first class connecting against BlazeDS!</p>
]]></content:encoded>
			<wfw:commentRss>http://wadearnold.com/blog/flash/blazeds-worth-figuring-out-helloworld-example/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>
