Using Flash Builder I need to create a data service with 2 parameters named start-index and max-results (for the YouTube API). In Flash Builder/Flex data services, parameter names can only contain letters, numbers and underscores. I temporarily used startIndex and maxResults intending to override these in the service’s superclass using its child class. It turns out it is not as simple as I thought and I have tried this numerous ways. If I overwrite the parameter names in the superclass it works fine, but this is inevitably overwritten because it is auto-generated. This is the superclass, _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;
}
}
You can see the parameter names in the line argsArray = new Array(“startIndex”,”maxResults”);
This is the child class, 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
}
}
}
How and where should I override this?
I think this was the way it was supposed to be done in TopRatedService.as :