e_schrade wrote a neat way of doing things in the service layer; Let’s take a quick look at something that’s kind of neat in Zend Framework. I’ve been doing some work with Adobe on some articles and one of them was on working with mobile clients with Flash. Well, me being the masochist I did more. What I did was write an example that worked as a full website, an Ajax website, a Flash service and an XML-RPC service.
Looks like a lot, right? Actually there’s not much there. Here’s the logic flow.
- Is it an XMLHTTP Request and is it a POST? Create the Json server
- Is it an AMF request? Create the AMF server
- Is it an XmlRpc request? Create the XmlRpc server
- Is it an XMLHTTP Request and is it a GET? Create the Service Map (for JSON-RPC 2.0)
- If a service handler has been created add all of the application’s mappers, attach the service handler to the request and redirect to the service action.
And with that you have an application that can serve content for multiple different types of service with almost no effort on your part. At least.. if you copy and paste this code.
Have a good Friday!!!