Using convertParametersHandler in Flex 4
There is avery handy API in Flex 4 RemoteObject and WebService. It lets you manipulate/validate parameters before calling the actual operation.
Suppose I have imported WebService http://ws.cdyne.com/WeatherWS/Weather.asmx?wsdl in FlashBuilder 4 . The service basically gives weather information. I want to validate/Change parameter ‘ZIPCODE’ of ‘GetCityWeatherByZIP’ when a service call happens. Here is what you need to do. In servicename.as class,
public class Weather extends _Super_Weather
{
public function Weather() {
_serviceControl.convertParametersHandler = convertParameterHandler;
}
public function convertParameterHandler(o:Array):Array {
//Dummy validation. If user gives '210' as value. Prefix it with '90' (Beverly Hills:-)
var str:String = o[0];
if(str.substr(0,2)!="90") //User gives only last 3 digits
str = "90"+str;
o[0] = str;
return o;
}
}
}