2011-11-05 190 views
1

我有一個flex 4.5 php應用程序,可以在localhost上完美運行。當我把它上傳到我的遠程主機,我遇到一個奇怪的問題,當我嘗試訪問產能釋放:搬到生產服務器

1. If I am the computer running my localhost, then the production site works. 

2. If I am on any other computer then the production site returns the error: "Send failed Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Failed: url: 'http://localhost/public/gateway.php'" 

總之,發佈版本正在尋找我的本地機器上的文件。我究竟做錯了什麼?如果你嘗試在Flash Builder 4中使用這個例子,那麼它就會工作。當你嘗試在遠程服務器上運行發佈版本時,問題只出現在Flash Builder 4.5中(你也必須訪問遠程網站,本地主機關閉,作爲瑞士法郎抓住從本地主機文件)

<?xml version="1.0" encoding="utf-8"?> 
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
      xmlns:s="library://ns.adobe.com/flex/spark" 
      xmlns:mx="library://ns.adobe.com/flex/mx" 
      xmlns:testclass="services.testclass.*" 
      minWidth="955" minHeight="600"> 
<fx:Script> 
    <![CDATA[ 
     import mx.controls.Alert; 
     import mx.events.FlexEvent; 

     protected function getService(event:FlexEvent):void 
     { 
      label2.text='this function did NOT work'; 
      testFunctionResult.token = testClass.testFunction(); 
     } 

    ]]> 
</fx:Script> 
<fx:Declarations> 
    <s:CallResponder id="testFunctionResult"/> 
    <testclass:TestClass id="testClass" 
         fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" 
         showBusyCursor="true"/> 
    <!-- Place non-visual elements (e.g., services, value objects) here --> 
</fx:Declarations> 
<s:VGroup width="100%" height="100%" x="75"> 
<s:Spacer height="25"/> 
<s:Label fontSize="18" color="Black" text="did this work?"/> 
<s:Label id="label2" color="Blue" 
     creationComplete="getService(event)" text="{testFunctionResult.lastResult}"/> 
</s:VGroup> 

</s:Application> 




<?php 
class TestClass{ 
public function testFunction(){ 
    return "this function worked"; 
} 
} 
?> 

回答

2

它看起來像你的生產SWF有被硬編碼到本地主機URL一些遠程調用。你必須找到並改變它

我會看看所有的RemoteObject,WebService和HTTPService調用應用程序,如果你使用Servic將es-config文件編譯到您的應用程序中;一定要在那裏看看。

+0

thx。這隻在我升級到4.5時才發生在Flex 4中。我找不到本地硬編碼的任何地方。 –

+0

您使用的是AMF/RemoteObject嗎?還是HTTPService?還是WebService? – JeffryHouser

+0

php w/ZendFramework –

1

加加先生,
我有同樣的問題。解決方案是在application/WEB-INF/flex/services-config.xml中設置相對路徑。我發現這個視頻的解決方案http://blog.themidnightcoders.com/index.php/2011/07/26/flex-remoting-urls-and-understanding-the-send-failed-error/

「編譯器將EMBEDS通道,端點和目標轉換爲SWF」視頻告訴。

首先我的頻道定義是這樣的:

 <channels> 
      <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel"> 
       <endpoint url="http://localhost:8080/applicationRoot/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/> 
      </channel-definition> 
     </channels> 

然後,我改變這樣的:

 <channels> 
      <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel"> 
       <endpoint url="/applicationRoot/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/> 
      </channel-definition> 
     </channels> 

現在我可以從遠程計算機連接的服務器。