Announcement Announcement Module
Collapse
No announcement yet.
Basic Flex/Spring Configuration Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Basic Flex/Spring Configuration

    I'm having a difficult time getting rc2 working with flex. I have experience with Flex, but I've never actually had to configure the remoting piece of it. I have an existing Spring project that utilizes spring mvc. I believe that I have the server side configured properly, I feel it might be a flex configuration at this point. My remote objects alway hit the fault handler and the trace on that doesn't produce anything helpful. I was wondering is someone has a bare bones flex and spring project setup that they might be able to post so I can have a look at how this is done. I will post some of the code below and maybe someone will see something obvious. Thanks in advance

    web.xml
    HTML Code:
    <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <listener>
    <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
    </listener>
    <listener>
    	<listener-class>flex.messaging.HttpFlexSession</listener-class>
    </listener>
    
    <servlet>
    	<servlet-name>springmvc</servlet-name>
    	<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    	<init-param>
    	<param-name>contextConfigLocation</param-name>
    	<param-value>/WEB-INF/config/springmvc-servlet.xml</param-value>
    	</init-param>
    	<load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    	<servlet-name>springmvc</servlet-name>
    	<url-pattern>*.html</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
            <servlet-name>springmvc</servlet-name>
            <url-pattern>/messagebroker/*</url-pattern>
    </servlet-mapping>

    application context.xml
    HTML Code:
    <flex:message-broker services-config-path="/WEB-INF/config/flex/services-config.xml">
         <flex:message-service default-channels="my-amf" />
    </flex:message-broker>
    services config
    HTML Code:
    <services>
      <service-include file-path="remoting-config.xml" />
            
      <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}/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
             <properties>
            	<polling-enabled>false</polling-enabled>
             </properties>
       </channel-definition>
    </channels>
    remoting config.xml
    HTML 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>
    </service>
    annotated remote bean
    Code:
    @Service("userService")
    @RemotingDestination(value = "userService", channels={"my-amf"})
    public class UserServiceImpl implements UserService {
    
    	@Override
    	@RemotingInclude
    	public User findByUserName(String userName) {
    		System.out.println(userName);
    		return null;
    	}
    
    	@Override
    	@RemotingInclude
    	public User saveUser(User user) {
    
    		return null;
    	}
    
    }

    And here is the mxml file from the flex project. I have also added the java server information to the project and it validated.
    HTML Code:
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    	
    <mx:Script>
    <![CDATA[
    import mx.rpc.events.FaultEvent;
    import mx.rpc.events.ResultEvent;
    			
    			
    private function handleClick(event:Event):void
    {
    	var name:String = "testUserName";
    	roUser.findByUserName(name);
    }
    
    private function handleFindUserByName(event:ResultEvent):void
    {
    	event.result as User;
    }
    			
    private function handleCreateFault(event:FaultEvent):void
    {
    	trace(event.message);
    }
    		
    ]]>
    </mx:Script>
    	
    <mx:RemoteObject id="roUser" destination="userService" >
    <mx:method name="saveUser" result="handleCreate(event)" fault="handleCreateFault(event)" />
    <mx:method name="findByUserName" result="handleFindUserByName(event)" fault="handleCreateFault(event)" />
    </mx:RemoteObject>
    	
    <mx:Button id="btn" label="Create" click="handleClick(event)" />
    Any suggestions or sample projects would be appreciated. Thanks

  • #2
    The server is the issue

    I got the remote call to go out from the client, I can't seem to get the server to respond to it. Part of the issue is that I'm using spring mvc and I'm annotating the remote destinations. Does anyone have the any experience getting the blazeds integration project working in conjunction with spring mvc?

    Comment


    • #3
      Have you gone through this thread?
      http://forum.springsource.org/showthread.php?t=69643

      Comment


      • #4
        Originally posted by jeremyg484 View Post
        Have you gone through this thread?
        http://forum.springsource.org/showthread.php?t=69643
        I haven't, I will check it out, thanks!

        Comment


        • #5
          So i read through that thread. I went in and created the second dispatcher and mapped it to its own servlet app context file and am now getting the following error when the client makes a remote call:
          No mapping found for HTTP request with URI [/sample/messagebroker/amf] in DispatcherServlet with name 'sampleamf'

          I have added and removed several of the beans posted in the thread but I get the same results. The services .xml I believe has the right config, it seems I can't find the right handler to connect it with my annotated rpc classes. Any ideas?

          Comment


          • #6
            So I did finally get this working. I had the second dispatcher created mapped to an empty web app context. The thread above is right, you have to also add the mapping /amf to the message broker, or in the web.xml add the mapping /messagebroker/amf instead of /messagebroker/*. With that it will work. However, I was unable to get it running in the same dispatcher as spring mvc, I kept running into tile def errors. I tried manually adding the various suggested beans to no avail. I hope to see more doc on this in the future, but at least it works.

            Comment

            Working...
            X