Bonsoir,
alors voila, j'ai fais un petit projet sous Maven avec Flex et Spring. C'est un simple HelloWorld, où la réponse est crée par une classe java. Donc jusque là rien de bien compliqué. Seulement, mon remoteObject n'a pas l'air d'envoyer de message, et surtout il ne provoque pas d'erreur.
Alors j'ai essayer avec GraniteDS, ca marchait pas et la j'ai essayé avec BlazeDS et spring integration, ca ne marche pas non plus. Je ne comprend pas pourquoi ! Tout à l'air bon
Le web.xml
Alors voilà l'applicationContext.xml
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 <web-app> <display-name>TestFront</display-name> <description>BlazeDS Application</description> <!-- Http Flex Session attribute and binding listener support --> <listener> <listener-class>flex.messaging.HttpFlexSession</listener-class> </listener> <!-- Front Controller de Spring MVC qui va gerer les requetes Flex --> <servlet> <servlet-name>Spring MVC Dispatcher Servlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <!-- Mapping des requetes pour le controlleur Spring --> <servlet-mapping> <servlet-name>Spring MVC Dispatcher Servlet</servlet-name> <url-pattern>/messagebroker/*</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> </web-app>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <!-- Maps request paths at /messagebroker to the BlazeDS MessageBroker --> <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="mappings"> <value> /*=flexMessageBroker </value> </property> </bean> <!-- Handler qui va gerer les differents canaux Flex ( AMF, Http ,...) --> <bean class="org.springframework.flex.messaging.servlet.MessageBrokerHandlerAdapter"/> <!-- Factory qui va creer le broker Flex --> <bean id="flexMessageBroker" class="org.springframework.flex.messaging.MessageBrokerFactoryBean" > <!-- Configuration du chemin vers le service-config.xml --> <!--property name="servicesConfigPath" value="/flex/services-config.xml" /--> </bean> <bean id="bookService" class="application.HelloWordService" /> <!-- Exportation du service Tudu sous le nom TuduService --> <bean id="book" class="org.springframework.flex.messaging.remoting.FlexRemotingServiceExporter"> <property name="messageBroker" ref="flexMessageBroker"/> <property name="service" ref="bookService"/> </bean> </beans>
Le services-config.xml
Le remote_config.xml
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 <services-config> <services> <service-include file-path="remoting-config.xml" /> <!-- Specifie un canal par default pour toutes destinations --> <default-channels> <channel ref="my-amf"/> </default-channels> </services> <channels> <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel"> <endpoint url="http://localhost:8080/testFront/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/> </channel-definition> </channels> <logging> <!-- You may also use flex.messaging.log.ServletLogTarget --> <target class="flex.messaging.log.ConsoleTarget" level="debug"> <properties> <prefix>[BlazeDS] </prefix> <includeDate>false</includeDate> <includeTime>false</includeTime> <includeLevel>true</includeLevel> <includeCategory>false</includeCategory> </properties> <filters> <pattern>Endpoint.*</pattern> <pattern>Service.*</pattern> <pattern>Configuration</pattern> </filters> </target> </logging> </services-config>
le mxml
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 <?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>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" horizontalAlign="center" verticalAlign="middle"> <mx:Script> <![CDATA[ import mx.messaging.AbstractConsumer; import mx.controls.Alert; private function faultHandler(event:FaultEvent):void{ Alert.show(event.fault.faultString); } ]]> </mx:Script> <mx:RemoteObject id="srv" destination="bookService" fault="faultHandler(event)"/> <mx:Panel styleName="Panel" title="Hello Word Sample"> <mx:Label text="Enter your name:"/> <mx:TextInput id="nameInput" /> <mx:Button label="Say Hello" click="srv.sayHello(nameInput.text)"/> </mx:Panel> <mx:Label styleName="Result" text="{srv.sayHello.lastResult}"/> </mx:Application>
et enfin mon java
Si quelqu'un à une idée, je suis preneur parce uqe la franchement ca fait longtemps que je cherche
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 package application; public class HelloWordService { public HelloWordService(){ System.out.println("construit!"); } public String sayHello(String name) { System.out.println("appel!"); return "Hello " + name + "!"; } }
Merki d'avance
Partager