Q:

What is a good web service for ajax interactions? in Zend Framework context?

When you are designing a page that will use javascript and ajax to interact with your server, what is the best technology you should use?
What I mean by using is basically things like sending and receiving data for simple CRUD, and things like autocompletion and search.
I usually write my own server, I read the $_POST variable, and I use Jquery's jQuery.post() to send stuff to the server and also read stuff.
I was wondering if I should use a more standard protocol such as:

XML_RPC 
REST
SOAP
JSON_RPC

Please tell me if I should be using any of these or something else, and also justify your response as to what protocol/technology is more suited for these kind of things.

A:

I tend to use REST/JSON because it's easiest and fastest in most cases. I hate XML parsing and Zend Framework supports creating a REST application very easily. On top of that, it would allow you to separate your view and data layers to different servers if you really needed to scale. I often have 'regular' controllers and REST controllers in the same modules, it's pretty easy to get the hang of.
The get/post/put/delete actions correspond to the HTTP request type
class MyRestController extends Zend_Rest_Controller
{

    public function init()
    {
        $this->_helper->viewRenderer->setNoRender(true);
    }

    public function indexAction()
    {
    }

    public function getAction()
    {
    }

    public function postAction()
    {
    }

    public function putAction()
    {
    }

    public function deleteAction()
    {
    }

}

And then you have to initialize the route in your bootstrap:
protected function _initRestRoute()
{
        $this->bootstrap('frontController');
        $frontController = Zend_Controller_Front::getInstance();
        $restRoute = new Zend_Rest_Route($frontController);
        $frontController->getRouter()->addRoute('default', $restRoute);

}

Some light reading:
http://www.techchorus.net/create-restful-applications-using-zend-framework
http://www.xfront.com/REST-Web-Services.html
http://www.develop.com/httpstatuscodesrest

