1 Reply Latest reply on Nov 8, 2011 12:54 AM by Nicholas_25

    Flex and BlazeDS Compile for Deployement




      I've been following the Flex + BlazeDS tutorial on the Message Service from adobe to start learning working with blazeds. Everything worked out great on the local server of course but I got stuck when it came to moving the files to a remote server. I've looked around quite a lot and found out it's because the compiler feeds the services-config.xml upon compile and at lease in my case won't take and external file. The solution everyone has been posting on the net is writing the channels in actionscript within flex and feedin it the valid endpoint that would be found in the xml configuration file. That's all nice and dandy but everyone has been talking and showing examples of this being done for RemoteObject and I haven't managed to find any examples for Messaging.


      Can anyone help me out with an example on how to deploy my application to a server? (either by coding the channels in AS or otherwise) The application itself is pretty basic...



      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
            xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="200" minHeight="480" creationComplete="consumer.subscribe()" width="250" currentState="EnterName">
         import mx.messaging.events.MessageEvent;
         import spark.events.TextOperationEvent;
        <s:State name="Chat"/>
        <s:State name="EnterName"/>
        <s:Producer id="producer" destination="chat"/>
        <s:Consumer id="consumer" destination="chat" message="messageHandler(event.message)"/>
         import mx.messaging.messages.AsyncMessage;
         import mx.messaging.messages.IMessage;
         private function send():void{
          var message:IMessage = new AsyncMessage();
          message.body.chatMessage = user.text + ":" + " " + msg.text;
          msg.text = "";
         private function messageHandler(message:IMessage):void{
          log.text += message.body.chatMessage + "\n";
       <s:Panel title="Chat" width="100%" height="100%">
        <s:TextArea id="log" height="377" x="10" y="10" width="228" includeIn="Chat"/>
        <mx:ControlBar width="246" height="52" x="1" y="395" includeIn="Chat">
         <s:TextInput id="msg" width="100%" enter="send()"/>
         <s:Button label="Send B" click="send()"/>
        <s:TextInput includeIn="EnterName" x="60" y="177" id="user" />
        <s:Button includeIn="EnterName" x="87" y="207" label="Start Chat" id="chat" click="chat_clickHandler(event)"/>
        <s:Label includeIn="EnterName" x="57" y="157" text="Please Enter Your Name"/>


      And besides that in the messaging-config.xml file on the server a destination with the id="chat" is created and that's it.


      Any help or pointing in the right direction will be greatly appreciated.


      Thank you,


        • 1. Re: Flex and BlazeDS Compile for Deployement
          Nicholas_25 Level 1



          Ok...I finally figured out that by replacing the tokens in the services-config.xml file with the physical address of the server everything works.


          Anyway...this means the application needs to be compiled everytime it is moved to a new server or even a different folder on the same server for that matter. Is there any way to pass the {server.name}, {server.port} and {context.root} tokens to the application at runtime for messaging?