Rendezvous with technology

serializationFilter in HTTPMultiService

Posted on: October 28, 2009

HTTPService/HTTPMultiService have a cool concept of a Serialization Filter. This mechanism let’s you configure and manipulate various aspects of the HTTP call like the request, response, etc..
A default implementation of SerializationFilter is provided in mx.rpc.http.SerializationFilter

Usage -
You can create a custom SerializationFilter by extending from the default implementation and set it on the HTTPService instance or the Operation instance.

A sample implementation can be as simple as processing the response from the service.
For example, if your service returns a comma (,) separated list of values, you can convert it to an Array here.

package
{
import mx.rpc.http.AbstractOperation;
import mx.rpc.http.SerializationFilter;

public class CustomSerializationFilter extends SerializationFilter
{	
	override public function deserializeResult
		(operation:AbstractOperation, result:Object):Object
	{
		var arr:Array = [];
		if (result is String)
		{
			arr = String(result).split(',');
		}
		return arr;
	}
}
}

And no, this is not all, there are other methods also which exposes more functionality.

For example, you can use the serializeURL() method to process/modify the url which this service/operation is about to invoke.

Livedocs here

About these ads

4 Responses to "serializationFilter in HTTPMultiService"

im still not understand about this ,,,, :(

Can you share which part of this feature you are not understanding?

Hi,

I try to dispatch rpc event via operation, to have a fault event for IResponder registred in service.token. I get only normal fault events like ERROR_DECODING etc… Is there a way to dispatch custom event in deserialization for faultResponder?:

var fault:Fault = new Fault(CUSTOM_ERROR, “Non XML response”,”details…”);
operation.dispatchRpcEvent(FaultEvent.createEvent(fault));

Thank you.

Hi,
i forget to add correct asyncToken for faultEvent. All is ok for now.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: