Announcement Announcement Module
Collapse
No announcement yet.
BlazeDS Integration in web-module without web.xml Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • BlazeDS Integration in web-module without web.xml

    Hi,

    I am currently setting up a project, based on the skeleton of the greenpages sample application as I really like the structure. After quit a lot of trial and error I finally have my application up and running and am currently trying to do first tests with flex clients.

    Unfortunately it seems the Springsource DM Server (currently still 1.x) seems to have problems with my web.xml ... after a little thinking it sounds sensible, since the spring configuration is initialized per default on deployment, so using the DispatcherServlet would configure my spring context a second time. After leaving the entire web.xml away (as it was with the greenpages example) everything seems to work fine. Except that I can't seem to be able to connect to my blazeds channels.

    I have an example channel configured in my services-config.xml with the following url:

    url="http://{server.name}:{server.port}/{context.root}/spring/messagebroker/amf"

    I have no mapping element in my message-broker configuration and am trying to access this channel in my flex client using the following code:

    <mx:AMFChannel id="myamf" uri="/ee/spring/messagebroker/amf"/>

    Unfortunately I am getting 404s all the time. What do I have to configure to get everything up and running?

    Chris

  • #2
    To make things a little more clear ... here my config-files:

    module-context.xml:
    PHP Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:flex="http://www.springframework.org/schema/flex"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
            http://www.springframework.org/schema/flex http://www.springframework.org/schema/flex/spring-flex-1.0.xsd"
        xmlns:context="http://www.springframework.org/schema/context">

        <!-- 
            Configure BlazeDS using the master configuration at "WEB-INF/flex/services-config.xml"
        -->
        <flex:message-broker id="_messageBroker" 
            services-config-path="/WEB-INF/flex/services-config.xml">
        </flex:message-broker>
        
        <!-- 
            Instantiate the flexAdapter 
        -->
        <bean id="flexAdapter" class="de.cware.cweb.adapter.flex.impl.FlexAdapterImpl">
            <property name="eventService" ref="eventService"/>
            <property name="loginService" ref="loginService"/>
            <property name="sessionService" ref="sessionService"/>
            <!-- 
                Make the flexAdapter available as flex service 
            --> 
            <flex:remoting-destination/>
        </bean>
    </beans>
    osgi-context.xml:
    PHP Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:osgi="http://www.springframework.org/schema/osgi"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd">
        
        <osgi:reference id="eventService" interface="de.cware.cweb.services.event.EventService"/>
        <osgi:reference id="loginService" interface="de.cware.cweb.services.login.LoginService"/>
        <osgi:reference id="sessionService" interface="de.cware.cweb.services.session.SessionService"/>
        
    </beans>
    flex/services-config.xml:
    PHP Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <services-config>
        <services>
            <default-channels>
                <channel ref="my-amf"/>
            </default-channels>
        </services>
        <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>
            <channel-definition id="my-polling-amf" class="mx.messaging.channels.AMFChannel">
                <endpoint
                    url="http://{server.name}:{server.port}/{context.root}/spring/messagebroker/amfpolling"
                    class="flex.messaging.endpoints.AMFEndpoint"/>
                <properties>
                    <polling-enabled>true</polling-enabled>
                    <polling-interval-seconds>4</polling-interval-seconds>
                </properties>
            </channel-definition>
        </channels>
    </services-config>
    The Bean Interface being published:
    PHP Code:
    package de.cware.cweb.adapter.flex;

    import java.util.Map;
    import java.util.UUID;

    public 
    interface 
    FlexAdapter 
    {
        public 
        
    UUID login(String usernameString password);
        
        public 
        
    void logout(UUID sessionId);
        
        public
        
    String get(UUID sessionIdString moduleMap<StringStringproperties);
        
        public
        
    String post(UUID sessionIdString moduleMap<StringStringpropertiesString payload);

    My Flex Application code:
    PHP Code:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
       creationComplete="login()">
       
     <mx:Script>
         <![CDATA[
             private function login():void
             {
                 srv.login("test","pass");
             }
         ]]>
     </mx:Script>
     
     <mx:AMFChannel id="myamf"
      uri="/ee/spring/messagebroker/amf"/>
     
     <mx:ChannelSet id="channelSet" channels="{[myamf]}"/>
     
     <mx:RemoteObject id="srv" 
       destination="flexAdapter" channelSet="{channelSet}"/>
     
     <mx:TextInput text="{srv.login.lastResult}"/>
    </mx:Application>

    Comment


    • #3
      Hi,

      it sort of becomes a habit of me answering my own questions ... but mabe it helps someone.

      The thing I was missing, was a Web-DispatcherServletUrlPatterns tag in my web-bundles MANIFEST.MF file. Now I have the following Web-Tags in it:
      Code:
      Module-Type: web
      Web-ContextPath: ee
      Web-DispatcherServletUrlPatterns: /spring/*
      I am now telling the DispatcherServlet to actively bind to request starting with "/spring" ... in my case all requests to urls "http://hosnameort/ee/spring"

      Additionally I added a mapping and a remoting-service element to my message-broker defintion. It now looks like this:
      Code:
      	<flex:message-broker id="_messageBroker" 
      		services-config-path="/WEB-INF/flex/services-config.xml">
      		<flex:mapping pattern="/messagebroker/*"/>
      		<flex:remoting-service default-adapter-id="java-object" 
      			default-channels="my-amf"/>
      	</flex:message-broker>
      After this I was successfully able to call the login method of my bean.

      I can't wait getting to work now that this "initial-setup-crap" is finished :-)

      Comment

      Working...
      X