0

使用 Flash Builder,我需要创建一个具有 2 个名为start-indexmax-results的参数的数据服务(用于 YouTube API)。在 Flash Builder/Flex 数据服务中,参数名称只能包含字母、数字和下划线。我暂时使用startIndexmaxResults打算使用其子类在服务的超类中覆盖这些。事实证明它并不像我想象的那么简单,我已经尝试了很多方法。如果我覆盖超类中的参数名称,它可以正常工作,但这不可避免地会被覆盖,因为它是自动生成的。这是超类_Super_TopRatedService.as

package services.topratedservice
{
**(imports here)**

[ExcludeClass]
internal class _Super_TopRatedService extends com.adobe.fiber.services.wrapper.HTTPServiceWrapper
{
    private static var serializer0:XMLSerializationFilter = new XMLSerializationFilter();

    // Constructor
    public function _Super_TopRatedService()
    {
        // initialize service control
        _serviceControl = new mx.rpc.http.HTTPMultiService();
         var operations:Array = new Array();
         var operation:mx.rpc.http.Operation;
         var argsArray:Array;

         operation = new mx.rpc.http.Operation(null, "getData");
         operation.url = "https://gdata.youtube.com/feeds/api/standardfeeds/top_rated";
         operation.method = "GET";
         argsArray = new Array("startIndex","maxResults");
         operation.argumentNames = argsArray;         
         operation.serializationFilter = serializer0;
         operation.properties = new Object();
         operation.properties["xPath"] = "/::entry";
         operation.resultElementType = valueObjects.Entry;
         operations.push(operation);

         _serviceControl.operationList = operations;  


         preInitializeService();
         model_internal::initialize();
    }        
    //init initialization routine here, child class to override
    protected function preInitializeService():void
    {

    }    
    /**
      * This method is a generated wrapper used to call the 'getData' operation. It returns an mx.rpc.AsyncToken whose 
      * result property will be populated with the result of the operation when the server response is received. 
      * To use this result from MXML code, define a CallResponder component and assign its token property to this method's return value. 
      * You can then bind to CallResponder.lastResult or listen for the CallResponder.result or fault events.
      *
      * @see mx.rpc.AsyncToken
      * @see mx.rpc.CallResponder 
      *
      * @return an mx.rpc.AsyncToken whose result property will be populated with the result of the operation when the server response is received.
      */
    public function getData(startIndex:int, maxresults:int) : mx.rpc.AsyncToken
    {
        var _internal_operation:mx.rpc.AbstractOperation = _serviceControl.getOperation("getData");
        var _internal_token:mx.rpc.AsyncToken = _internal_operation.send(startIndex,maxresults) ;
        return _internal_token;
    }         
}

您可以在argsArray = new Array("startIndex","maxResults");行中看到参数名称

这是子类TopRatedService.as

package services.topratedservice
{    
public class TopRatedService extends _Super_TopRatedService
{
    /**
     * Override super.init() to provide any initialization customization if needed.
     */
    protected override function preInitializeService():void
    {
        super.preInitializeService();
        // Initialization customization goes here
    }                   
}    
}

我应该如何以及在哪里覆盖它?

4

1 回答 1

0

我认为这是应该在TopRatedService.as中完成的方式:

protected override function preInitializeService():void
    {
        super.preInitializeService();
        // Initialization customization goes here
        super._serviceControl.operations.getData.argumentNames= new Array("start-index","max-results")
    }
于 2012-05-19T16:55:44.530 回答