人在江湖

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            82 Posts :: 10 Stories :: 169 Comments :: 0 Trackbacks
          在學會了blazeds的簡單配置之后,今天嘗試了一下spring blazeds integration配置,被網上很多帖子坑了,比如這篇貌似不錯的:http://www.adobe.com/devnet/flex/articles/spring_blazeds_integration.html
          按照這篇文章的方式配置,會得到錯誤:
          [RPC Fault faultString="[MessagingError message='Destination 'XXXX' either does not exist or the destination has no channels defined (and the application does not define any default channels.)']" faultCode="InvokeFailed" faultDetail="Couldn't establish a connection to 'userService'"]
          在網上查原因,嘗試了3個多小時,才終于搞定,靠。
          第一步: 下載blazeds的sample, https://www.adobe.com/cfusion/entitlement/index.cfm?e=lc_blazeds 下載那個40多M的turnkey,里面包含tomcat和sample application.
          第二步:webapp目錄下有個blazeds目錄,這是做blazeds項目的一個基礎app, 新的app可以基于這個來做,lib目錄下已經包含相應的jar包了,一些configuration文件也都已經包括了。可以在當前目錄再復制粘貼出來一個副本,我命名為spring_blazeds。
          第三步:改web.xml,內容如下:
          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
          <web-app>
              <display-name>BlazeDS</display-name>
              <description>BlazeDS Application</description>
          <servlet>
                <servlet-name>spring</servlet-name>
                   <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
                   <init-param>
                      <param-name>contextConfigLocation</param-name>
                      <param-value>/WEB-INF/web-application-context.xml</param-value>
                   </init-param>
                   <load-on-startup>1</load-on-startup>
             </servlet>
           
             <servlet-mapping>
                 <servlet-name>spring</servlet-name>
                 <url-pattern>/messagebroker/*</url-pattern>
             </servlet-mapping>
          </web-app>
          第四步:web-inf目錄下添加文件web-application-context.xml,內容如下:
          <?xml version="1.0" encoding="UTF-8"?>
          <beans xmlns="http://www.springframework.org/schema/beans"
          xmlns:flex="http://www.springframework.org/schema/flex"
          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-3.0.xsd
          http://www.springframework.org/schema/flex 
          http://www.springframework.org/schema/flex/spring-flex-1.0.xsd">
          <!-- Bootstraps and exposes the BlazeDS MessageBroker simplest form -->
          <flex:message-broker/>
           
             <bean id="productService" class="flex.samples.product.ProductService" >
                <flex:remoting-destination />
             </bean>
          </beans>
          第五步:
          把web-inf/flex目錄下的services-config.xml的前幾行改成:
          <?xml version="1.0" encoding="UTF-8"?>
          <services-config>
              <services>
                  <default-channels>
                      <channel ref="my-amf"/>
                  </default-channels>
              </services>
          這一步非常重要,我好幾個小時沒搞定問題,主要差的就是這一步!web-inf/flex目錄下的其他文件沒用,至少在這個例子里沒用。
          第六步:
          寫mxml文件:
          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" backgroundColor="#FFFFFF">
          <mx:RemoteObject id="srv" destination="productService"/>
          <mx:DataGrid dataProvider="{srv.getProducts.lastResult}" width="100%" height="100%"/> 
          <mx:Button label="Get Data" click="srv.getProducts()"/>
          </mx:Application>
          第七步:
          把turnkey里blazeds-turnkey-4.0.0.14931\tomcat\webapps\samples\WEB-INF\src\flex\samples\product目錄下的java文件編譯一下,放web-inf的classes目錄下。
          第八步:
          添加jar包,編譯mxml,把bin-debug目錄下的所有文件包括history目錄都拷貝到webroot下,我的是spring_blazeds。記得編譯時加選項
          -services "C:\code\flex\blazeds-turnkey-4.0.0.14931\tomcat\webapps\spring_blazeds\WEB-INF\flex\services-config.xml" -locale en_US
          所以你每次改services-config.xml都要重新編譯,替換webapp的文件。

          然后運行應該就可以了!
          posted on 2013-06-07 15:08 人在江湖 閱讀(1930) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 洛阳市| 霞浦县| 睢宁县| 喀什市| 小金县| 张家口市| 崇义县| 岳阳县| 大竹县| 扎兰屯市| 临江市| 贡山| 石林| 济源市| 绍兴县| 山阴县| 河西区| 深水埗区| 绵阳市| 铅山县| 怀仁县| 巴南区| 高碑店市| 梁河县| 钟祥市| 龙陵县| 绥棱县| 丰都县| 利津县| 梁平县| 永昌县| 包头市| 象山县| 阜宁县| 建宁县| 梁平县| 麻城市| 鄄城县| 乐山市| 贵州省| 弥渡县|