2011-01-24 2 views
0

Я хочу использовать интеграцию Spring BlazeDS.Как использовать интеграцию Spring BlazeDS?

Я пишу их так.

[web.xml]

<servlet> 
    <servlet-name>flex</servlet-name> 
    <servlet-class> 
     org.springframework.web.servlet.DispatcherServlet 
    </servlet-class> 
    <init-param> 
     <param-name>contextConfigLocation</param-name> 
     <param-value>/WEB-INF/classes/applicationContext.xml</param-value> 
    </init-param> 
    <load-on-startup>1</load-on-startup> 
</servlet> 
<servlet-mapping> 
    <servlet-name>flex</servlet-name> 
    <url-pattern>/messagebroker/*</url-pattern> 
</servlet-mapping> 

[WEB-INF/классы/applicationContext.xml]

<?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/flex 
      http://www.springframework.org/schema/flex/spring-flex-1.0.xsd 
      http://www.springframework.org/schema/beans 
      http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> 


    <flex:message-broker/> 

    <bean id="hogeService" class="hoge.HogeServiceImpl"> 
     <flex:remoting-destination /> 
    </bean> 
</beans> 

[WEB-INF/Flex/услуги-config.xml]

<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}/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/> 
     </channel-definition> 
</services-config> 

Итак, я называю «hogeService» из приложения Flex следующим образом.

var ro:RemoteObject = new RemoteObject(); 
ro.destination = "hogeService"; 
ro.hoge(); // HogeServiceImpl class has "hoge" method with no arguments. 

Тогда у меня появилось сообщение об ошибке.

[RPC Fault faultString="[MessagingError message='Destination 'hogeService' either does not exist or the destination has no channels defined (and the application does not define any default channels.)']" faultCode="InvokeFailed" faultDetail="メッセージ送信先への接続を確立できませんでした。"] 

Зачем мне это сообщение об ошибке? И, пожалуйста, скажите мне какие-либо решения.

ответ

2

Убедитесь, что у вас есть свои службы-config.xml, также переданные компилятору flex (compc или mxmlc) в качестве флага compiler.services.

В качестве альтернативы, вы можете позволить RemoteObject построить канал (который затем отсоединяется клиент и сервер конфигурации полностью), например, так:

var ro:RemoteObject = RemoteObject(); 
ro.endpoint = "http://{server.name}:{server.port}/{context.root}/messagebroker/amf"; // this internally constructs an AMFChannel or SecuredAMFChannel depending on the protocol 
ro.hoge(); 
0

С последними версиями интеграции Spring BlazeDS вам просто нужно добавьте кое-что к своему диспетчеру Spring, чтобы все могло работать, хотя я считаю, что вам все еще нужны все службы-config.xml и т. д. для самого Flex.

<flex:message-broker> 
    <flex:message-service default-channels="amf"/> 
</flex:message-broker> 
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> 
    <property name="mappings"> 
    <value> 
     /*=_messageBroker 
    </value> 
    </property> 
</bean> 
<bean class="org.springframework.flex.servlet.MessageBrokerHandlerAdapter"/> 
Смежные вопросы