如何使用Spring BlazeDS集成?

发布于 2024-10-14 02:20:55 字数 2607 浏览 7 评论 0原文

我想使用 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/classes/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/services-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>

因此,我从 Flex 应用程序中调用“hogeService”,如下所示。

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="メッセージ送信先への接続を確立できませんでした。"]

为什么我会收到此错误消息? 请告诉我任何解决方案..

I want to use Spring BlazeDS Integration.

I write them like this.

[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/classes/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/services-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>

So, I call "hogeService" from Flex application like this.

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

Then, I got an error message like this.

[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="メッセージ送信先への接続を確立できませんでした。"]

Why do I get this error message ?
And please tell me any solutions..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

思念满溢 2024-10-21 02:20:55

确保您的 services-config.xml 也作为标志 compiler.services 传递给了 Flex 编译器(compc 或 mxmlc)。

或者,您可以让 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();

Make sure you have have your services-config.xml also passed to the flex compiler (compc or mxmlc) as the flag compiler.services.

Alternatively, you can let the RemoteObject build the channel (which then decouples the client and the server config completely), like so:

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();
桃扇骨 2024-10-21 02:20:55

使用最新版本的 Spring BlazeDS 集成,您只需要向 Spring 调度程序添加一些东西即可正常工作,尽管我相信您仍然需要 Flex 本身的所有 services-config.xml 等。

<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"/>

With the latest versions of the Spring BlazeDS integration you just need to add a little something to your Spring dispatcher in order for things to work, though I believe you still need all the services-config.xml etc for Flex itself.

<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"/>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文