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
services configHTML Code:<flex:message-broker services-config-path="/WEB-INF/config/flex/services-config.xml"> <flex:message-service default-channels="my-amf" /> </flex:message-broker>
remoting config.xmlHTML 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>
annotated remote beanHTML 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>
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.
Any suggestions or sample projects would be appreciated. ThanksHTML 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)" />


Reply With Quote
