簡體   English   中英

這個 Flex 前端應用程序如何連接到我的后端應用程序? mx:RemoteObject URL 端點 URL 在哪里定義?

[英]How this Flex front end application is connected to my back end application? Where the mx:RemoteObject URL endpoint URL are defined?

我絕對是Flex新手。

我正在開發一個舊的(由其他人制作的)應用程序,它具有以下架構:從Java后端應用程序接收數據的Flex前端。

我拼命想了解前端是如何連接到前端的(我必須部署這個應用程序,所以我需要將后端指針更改為Flex前端應用程序)。

進入我的FLEX前端,我發現這個MyAppServices.mxml文件包含一些應在 MXML 文件中表示 HTTPService 對象的標記。

閱讀官方文檔:

此標記使您可以使用 Action Message Format (AMF) 編碼訪問 Java 對象的方法。

所以它應該是指向我的后端服務的指針:

<?xml version="1.0" encoding="utf-8"?>
<rds:ServiceLocator 
    xmlns:mx="http://www.adobe.com/2006/mxml" 
    xmlns:rds="com.adobe.cairngorm.business.*">
    <mx:Script>
        <![CDATA[
            import org.myOrganization.myApp.util.ConfigServer;
        ]]>
    </mx:Script>


    <mx:RemoteObject 
        id="genericService"     
        destination="genericService"  
        endpoint= "messagebroker/amf" 
        showBusyCursor="true" 
        requestTimeout="100"
        />

    <mx:RemoteObject 
        id="themeService"       
        destination="themeService"  
        endpoint= "messagebroker/amf" 
        showBusyCursor="true" 
        requestTimeout="100"
        />

    <mx:RemoteObject 
        id="dataService"        
        destination="dataService"  
        endpoint= "messagebroker/amf" 
        showBusyCursor="true" 
        requestTimeout="100"
        />

    <mx:RemoteObject 
        id="userService"        
        destination="userService"  
        endpoint= "messagebroker/amf" 
        showBusyCursor="true" 
        requestTimeout="100"
        />

</rds:ServiceLocator>

所以,好吧……我想我已經找到了 Java 后端服務端點的定義位置。

但是……Java 后端 URL 在哪里定義?!?!

檢查以前的MyAppServices.mxml文件的代碼,我可以看到包含此​​部分:

<mx:Script>
    <![CDATA[
        import org.myOrganization.myApp.util.ConfigServer;
    ]]>
</mx:Script>

這應該會將包含在org.myOrganization.myApp.util.ConfigServer文件中的ActionScript代碼導入。

所以,在我的項目中,我找到了這個文件: org.myOrganization.myApp.util.ConfigServer.as

如您所見,路徑相同,但項目中存在的文件具有.as擴展名。 是自動添加的嗎?

所以這個文件的代碼是:

package org.myOrganization.myApp.util {
    import flash.events.HTTPStatusEvent;
    import flash.events.IOErrorEvent;
    import flash.events.ProgressEvent;
    import flash.events.SecurityErrorEvent;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.net.URLVariables;

    import mx.collections.ArrayCollection;
    import mx.core.Application;
    import mx.managers.BrowserManager;
    import mx.managers.IBrowserManager;
    import mx.utils.URLUtil;

    import org.osmf.utils.URL;

    public class ConfigServer {

        // settings
        public static var BIRT_URL:String;
        public static var GEOSERVER_URL:String;
        public static var GEOSERVER_BASELAYER_URL:String;
        public static var APP_CONTEXT:String;
        public static var CAF_SERVER_URL:String;
        public static var CAF_REGISTER_URL:String;

        public static var CAF_FACEBOOK_LOGIN_URL:String;
        public static var CAF_GOOGLE_LOGIN_URL:String;
        public static var CAF_TWITTER_LOGIN_URL:String;

        public static var CAF_FACEBOOK_REGISTER_URL:String;
        public static var CAF_GOOGLE_REGISTER_URL:String;
        public static var CAF_TWITTER_REGISTER_URL:String;

        public static var CAF_FACEBOOK_LOGIN_ENABLED:Boolean;
        public static var CAF_GOOGLE_LOGIN_ENABLED:Boolean;
        public static var CAF_TWITTER_LOGIN_ENABLED:Boolean;

        public static var CAF_FACEBOOK_REGISTER_ENABLED:Boolean;
        public static var CAF_GOOGLE_REGISTER_ENABLED:Boolean;
        public static var CAF_TWITTER_REGISTER_ENABLED:Boolean;

        //operations
        public static var LIST_BYID:String = "listById";
        public static var RESOURCES_NUMBER = "resourceNumber";
        public static var LIST_OPERATION:String = "list";
        public static var GET_OBJECT:String = "getObject";
        public static var ADD_OPERATION:String = "add";
        public static var DELETE_OPERATION:String = "delete";
        public static var UPDATE_OPERATION:String = "update";
        public static var REPORT_OPERATION = "report";
        public static var GET_BYID:String = "getById";
        public static var LIST_UPDATE_OPERATION:String = "listUpdate";  
        public static var APP_SETTINGS = "appSettings";     


        [Bindable]
        public static var VARIABLES_URL:String = "prop.properties";

        [Bindable]
        public static var arrColl:ArrayCollection;

        [Bindable]
        public static var paramColl:ArrayCollection;

        public static var urlReq:URLRequest;
        public static var urlLdr:URLLoader;

        public static function init():void {
            /* Initialize the two ArrayCollections objects with empty arrays. */
            arrColl = new ArrayCollection();
            paramColl = new ArrayCollection();

            /* Initialize the URLRequest object with the URL to the file of name/value pairs. */
            urlReq = new URLRequest(VARIABLES_URL);

            /* Initialize the URLLoader object, assign the various event listeners, and load the specified URLRequest object. */
            urlLdr = new URLLoader();
            urlLdr.addEventListener(Event.COMPLETE, doEvent);
            urlLdr.addEventListener(Event.OPEN, doEvent);
            urlLdr.addEventListener(HTTPStatusEvent.HTTP_STATUS, doEvent);
            urlLdr.addEventListener(IOErrorEvent.IO_ERROR, doEvent);
            urlLdr.addEventListener(ProgressEvent.PROGRESS, doEvent);
            urlLdr.addEventListener(SecurityErrorEvent.SECURITY_ERROR, doEvent);
            urlLdr.load(urlReq);
        }

        public static function doEvent(evt:Event):void {
            arrColl.addItem({type:evt.type, idx:arrColl.length+1, eventString:evt.toString()});

            switch (evt.type) {
                case Event.COMPLETE:
                    /* If the load was successful, create a URLVariables object from the URLLoader.data property and populate the paramColl ArrayCollection object. */
                    var ldr:URLLoader = evt.currentTarget as URLLoader;
                    var vars:URLVariables = new URLVariables(ldr.data);
                    var key:String;

                    for (key in vars) {
                        paramColl.addItem({key:key, value:vars[key]});
                    }

                    //params.visible = true;
                    break;
            }
        }



//      public static function getCurrentUrl():String {
//          var browserManager:IBrowserManager = BrowserManager.getInstance();
//          
//          var url:String = browserManager.url;
//          var result : String = url;       
//          if ( url && ( url.indexOf("file:/") == -1 ) )       
//          {          
//              //result = mx.utils.URLUtil.getFullURL(url, url);
//              result = mx.utils.URLUtil.getProtocol(url)+ "://" +mx.utils.URLUtil.getServerNameWithPort(url);
//
//          }       
//          return result;
//      }
//      
//      [Bindable] 
//      public static var properties:Object = new Object(); 
//      private static var loadedProps:Properties = new Properties();   
//      private function init():void {    
//          loadedProps.addEventListener(Event.COMPLETE, onLoaderComplete);     
//          loadedProps.addEventListener(IOErrorEvent.IO_ERROR, onIOError);     
//          loadedProps.load("prop.properties");
//          loadedProps.s
//      }   
//      
//      private function onLoaderComplete(event:Event):void {     
//          properties.host = loadedProps.getProperty("host");     
//          properties.port = loadedProps.getProperty("port");     
//          properties.webcontext = loadedProps.getProperty("context-root"); 
//      }
    }       
}

但在這里我也找不到我的服務器定義。

在這段代碼中有:

[Bindable]
public static var VARIABLES_URL:String = "prop.properties";

我認為它將prop.properties文件的內容導出到VARIABLES_URL變量中(我絕對不確定這種行為),但我的項目中沒有prop.properties文件。

您是否對在此 Flex 項目中定義后端端點 URL 的位置有所了解? 或者至少有一些關於如何搜索它的提示?

它可能包含在您的 services-config.xml 文件中。 檢查您的編譯器選項,看看是否有 -services=path/to/your/services-config.xml。

這里有更多信息。 http://www.adobe.com/devnet/livecycle/articles/externalize_serviceconfig.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM