Announcement Announcement Module
Collapse
No announcement yet.
Configuring the flex app Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Configuring the flex app

    Hi,
    I am trying to convert a sample of mine but I think I am missing something. The docs are talking about the configuration of the services in services-config.xml and remoting-config.xml. The remoting.xml can be pretty much left with some defaults. You do not have to configure the destinations.

    In the log files I can see this going for the server side. I see that the configured classes are used. However, I am having some problems at the client. There I cannot find the destinations. Am I doing something wrong? Should I now configure the client differently from the server?

    Following my code for the configuration, the commented part is the bean now exposed using the spring integration.
    Code:
    <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="bookManager">-->
        <!--<properties>-->
        <!--<factory>spring</factory>-->
        <!--<source>bookManager</source>-->
        <!--</properties>-->
        <!--</destination>-->
    
        <destination id="authenticationHelper">
            <properties>
                <source>nl.gridshore.samples.books.web.security.AuthenticationHelper</source>
            </properties>
        </destination>
    
    </service>
    If I change this for the client into:
    Code:
    <?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="remoteBookManager"/>
    
        <destination id="authenticationHelper">
            <properties>
                <source>nl.gridshore.samples.books.web.security.AuthenticationHelper</source>
            </properties>
        </destination>
    
    </service>
    Than it all seems to work, no I have the problem I cannot share config files, Allthough I like it that I only need to define the destinations without any hassle of factories etc. I still need to know the name of the bean that is exposed. It feels like something that cannot be overcome by the spring blazeds library.

    Am I right?

    Jettro
    Last edited by jettro; Dec 23rd, 2008, 03:01 AM.

  • #2
    Originally posted by jettro View Post
    However, I am having some problems at the client. There I cannot find the destinations.
    What do you mean exactly? I'm assuming you mean when referencing the services at runtime with a RemoteObject?

    It should definitely work without having to add
    Code:
    <destination id="remoteBookManager"/>
    for the client.

    Are you perhaps not accessing the destination by the correct identifier? The dynamic destination is configured such that by default the id is the same as the bean id of the exporter, though that is configurable via the serviceId property of the exporter.

    Comment


    • #3
      Yes I mean from code, I do create the services programmatically. I did manage to get it working with a custom build channelset. It seems the client does not know how to connect to the destination because the client does not know it.

      Code:
      public class BookService extends RemoteService {
              public function BookService(channelSet:ChannelSet) {
                  super("bookService", "remoteBookManager",channelSet);
              }
      }
      
      public class RemoteService {
          protected var remoteObject:RemoteObject;
      
              public function RemoteService(id:String, destination:String, channelSet:ChannelSet) {
                  this.remoteObject = new RemoteObject(id);
                  this.remoteObject.destination = destination;
                  this.remoteObject.channelSet = channelSet;
                  this.remoteObject.addEventListener(FaultEvent.FAULT,onRemoteException);
              }
      }
      With the config file I cannot make this work.

      I'll do some more experimentation to nail this one doen

      Originally posted by jeremyg484 View Post
      What do you mean exactly? I'm assuming you mean when referencing the services at runtime with a RemoteObject?

      It should definitely work without having to add
      Code:
      <destination id="remoteBookManager"/>
      for the client.

      Are you perhaps not accessing the destination by the correct identifier? The dynamic destination is configured such that by default the id is the same as the bean id of the exporter, though that is configurable via the serviceId property of the exporter.

      Comment


      • #4
        Ahh, okay I see. Yes, I do think assigning the ChannelSet to the RemoteObject is the key there. I don't think there's any getting around that when using dynamic destinations.

        See here:
        http://livedocs.adobe.com/blazeds/1/...econfig_1.html

        Though I believe if you have "my-amf" set up as an application-wide default, it would work without needing to explicitly specify the ChannelSet.

        For example, from the services-config.xml in the BlazeDS sample:

        Code:
        <services>
                
                <service class="flex.samples.DatabaseCheckService" id="hsqldb" />
                
                <service-include file-path="remoting-config.xml" />
                <service-include file-path="proxy-config.xml" />
                <service-include file-path="messaging-config.xml" />
                
        	    <service class="flex.samples.runtimeconfig.EmployeeRuntimeRemotingDestination" id="runtime-employee-ro" />
        
            	<!-- 
            	Application level default channels. Application level default channels are 
            	necessary when a dynamic destination is being used by a service component
            	and no ChannelSet has been defined for the service component. In that case,
            	application level default channels will be used to contact the destination.
                -->   
                <default-channels>
                   <channel ref="my-amf"/>
                </default-channels>
            
        </services>

        Comment


        • #5
          I have a similar issue here. I have configured the server as suggested. But, when i make a call from the client i get the following error:

          Code:
          message='Destination 'loginService' either does not exist or the destination has no channels defined

          remoting-service

          Code:
          <?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>
          
          </service>

          services-config.xml
          Code:
              <channels>
                  <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
                      <endpoint url="http : / / {server.name}:{server.port}/{context.root}/spring/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
                  </channel-definition>

          Spring beans
          Code:
          	<bean id="loginServiceController" class="org.phoenix.core.LoginService" />
          	    
          
          	<bean id="loginService" class="org.springframework.flex.messaging.remoting.FlexRemotingServiceExporter">
          		<property name="service" ref="loginServiceController"/>
          		<property name="messageBroker" ref="messageBrokerFactory"/>
          	</bean>
          What am i missing?

          Comment


          • #6
            Not sure whether they're typos or not, but it's supposed to be remoting-config.xml (not remoting-service) and there are some spaces in the endpoint URL in the services-config.xml which may cause some unexpected behaviour.

            Comment


            • #7
              Not sure whether they're typos or not, but it's supposed to be remoting-config.xml (not remoting-service)
              The remoting-service is defined in the Services-config file. The only thing that you have to worry about is to ensure that file name matches the one provided in services-config.xml

              some spaces in endpoint URL
              - I did this because i was not allowed to post URL possibly because of being a new user.

              Comment


              • #8
                Somebody wants to try it out?

                I have a sample that I have been using for a while and I have re-written it with the blazeds spring integration. I still have the same problem as mentioned in this thread. It only works when I add an empty destination to the client side configuration. If someone has the time to try it out:

                http://code.google.com/p/gridshore/s...books-overview

                It is all maven, so you can build it using maven, do make sure you have the M1 of the integration in you repository.

                You can start the application using jetty integrated with maven:
                cd books-web
                mvn clean jetty:run-war

                Open the link
                http://localhost:8080:/books-web

                Comment


                • #9
                  While i try the application...!!


                  Originally posted by jettro View Post
                  It only works when I add an empty destination to the client side configuration.
                  I am surprised that this works for you, because when I compile my application with an entry in remoting-service, I get an error on my web server, which says that I have the service exposed twice one in remoting-service and other in the spring-bean configuration.

                  However, I tried by creating a channel in my code-behind and assigned that channel to my remote service. It worked.

                  Comment


                  • #10
                    Originally posted by k.v.ahuja View Post
                    While i try the application...!!


                    I am surprised that this works for you, because when I compile my application with an entry in remoting-service, I get an error on my web server, which says that I have the service exposed twice one in remoting-service and other in the spring-bean configuration.

                    However, I tried by creating a channel in my code-behind and assigned that channel to my remote service. It worked.
                    I only added the destination to the client, so I duplicated the files. Yes I know that is not clean, but for the time being it does work. As for the Channels in code, yes I did that as well and for me it worked also. I am planning on using the other spring-flex module. The action script integration. There was some example code for configuring a channel using the xml config.

                    Comment


                    • #11
                      Originally posted by jettro View Post
                      I am planning on using the other spring-flex module. The action script integration. There was some example code for configuring a channel using the xml config.
                      I would definitely recommend this, as it externalizes and decouples things nicely. Using this approach you ultimately don't have to compile your Flex app against services-config.xml at all and can potentially deploy the back end and Flex front end as separate modules.

                      For those who haven't seen it yet, check out Christophe Herreman's blog on the matter:
                      http://www.herrodius.com/blog/158

                      Comment


                      • #12
                        Originally posted by jettro View Post
                        I am planning on using the other spring-flex module. The action script integration. There was some example code for configuring a channel using the xml config.
                        I am almost ready to write a XML based configuration. If you have this available as a source already, can you point me to that?

                        Comment


                        • #13
                          Originally posted by k.v.ahuja View Post
                          I am almost ready to write a XML based configuration. If you have this available as a source already, can you point me to that?
                          I meant the blog that Jeremy already pointed to in the previous comment

                          Comment


                          • #14
                            If you are looking for an example of a client using the Spring ActionScript library to connect to endpoints you can have a look at my latest blog post:
                            http://www.gridshore.nl/2009/01/06/c...-actionscript/

                            This is a start, not necessarily the best way.

                            greetz Jettro

                            Comment


                            • #15
                              Explicit channel set creation

                              Just to be pedantic. Here is an example to address the "message='Destination 'loginService' either does not exist or the destination has no channels defined" error in the M1 build.


                              // Define a ChannelSet object.
                              private var cs:ChannelSet;

                              // Replace 'server.mydomain.com' and 'myproject' with appropriate identifiers for your environment.
                              private function createChannelSet():ChannelSet {
                              if (cs == null) {
                              cs = new ChannelSet();
                              var ac:AMFChannel = new AMFChannel("sketchThree","http://server.mydomain.com:8080/myproject/messagebroker/amf");
                              cs.addChannel(ac);
                              }
                              return cs;
                              }

                              // Pass the ChannelSet explicitly to the RemoteObject call.

                              Comment

                              Working...
                              X