2009-06-17 121 views
4

我一直在嘗試在Flex應用程序中爲支持http/s請求找到正確的配置。我讀過的所有文檔,他們暗示做類似如下:如何在Flex/BlazeDS中同時支持HTTP和HTTPS通道?

<default-channels> 
    <channel ref="my-secure-amf"> 
    <serialization> 
     <log-property-errors>true</log-property-errors> 
    </serialization> 
    </channel> 
    <channel ref="my-amf"> 
    <serialization> 
     <log-property-errors>true</log-property-errors> 
    </serialization> 
    </channel> 

這打擊通過HTTPS的應用程序,但通過http擊中同一個應用程序時,得到間歇性通信故障時的偉大工程。這裏是一個縮寫服務-config.xml中:

<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> 
     <!-- HTTPS requests don't work on IE when pragma "no-cache" headers are set so you need to set the add-no-cache-headers property to false --> 
     <add-no-cache-headers>false</add-no-cache-headers> 
     <!-- Use to limit the client channel's connect attempt to the specified time interval. --> 
     <connect-timeout-seconds>10</connect-timeout-seconds> 
     </properties> 
    </channel-definition> 

    <channel-definition id="my-secure-amf" class="mx.messaging.channels.SecureAMFChannel"> 
     <!--<endpoint url="https://{server.name}:{server.port}/{context.root}/messagebroker/amfsecure" class="flex.messaging.endpoints.SecureAMFEndpoint"/>--> 
     <endpoint url="https://{server.name}:{server.port}/{context.root}/messagebroker/amfsecure" 
       class="flex.messaging.endpoints.AMFEndpoint"/> 
     <properties> 
     <add-no-cache-headers>false</add-no-cache-headers> 
     <connect-timeout-seconds>10</connect-timeout-seconds> 
     </properties> 
    </channel-definition> 

我使用Tomcat 5.5.17和Java 5.運行

  1. BlazeDS的文件說,這是最好的做法。有沒有更好的辦法?
  2. 使用這個配置,似乎有2-3個重試與default-channels元素中定義的每個通道相關聯,所以在my-amf通道通過http請求連接之前,它總是需要約20秒。有沒有辦法重寫2-3次重試,每次重試1次?

在此先感謝您的答案。

回答

3

我有http和https工作,雖然我只在Firefox和IE7上測試過它。到目前爲止,我只使用BlazeDS進行遠程處理。這裏是我的設置:

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

    <channel-definition id="my-secure-amf" 
     class="mx.messaging.channels.SecureAMFChannel"> 
     <endpoint 
      url="https://{server.name}:{server.port}/{context.root}/messagebroker/amfsecure" 
      class="flex.messaging.endpoints.SecureAMFEndpoint" /> 
     <properties> 
      <add-no-cache-headers>false</add-no-cache-headers> 
     </properties> 
    </channel-definition> 

你不指定你正在使用的應用程序服務器;這可能是一個問題。在Tomcat下從HTTPS切換到HTTP(安全登錄)時,我遇到了一些問題。我做過的一件事是安裝Jetty並在那裏嘗試。我以前從未使用過它,但即使通過Eclipse也可以很快進行設置和部署。然後我知道我有一個Tomcat特定問題,這使得找到一個解決方案更容易(我的意思是說可能)。

0

如果使用http和https的目的地是不同的目的地,則可以使用該目的地的訂單來定義通道。例如,mySecureDestination和myDestination是兩個不同的目的地。對於mySecureDestination:

<destination id="mySecureDestination" channels="httpsChannel"></destination> 

和非安全的HTTP通道

<destination id="myDestination" channels="httpChannel"></destination> 
1

這是我們駕駛過的堅果。爲了解決這個問題,http(my-amf)首先在default-channels標記中,然後https(my-secure-amf)

<default-channels> 
    <channel ref="my-amf"> 
<serialization> 
    <log-property-errors>true</log-property-errors> 
</serialization> 
</channel> 
<channel ref="my-secure-amf"> 
    <serialization> 
    <log-property-errors>true</log-property-errors> 
</serialization> 
</channel> 
相關問題