Jump to content

Developing a web service


Recommended Posts

I've created a Prestashop module with a table that needs to be exposed to our clients. This exposure needs to happen through the Prestashop web services, just like every other model entity in Prestashop is made available via REST.


I've created the required code that allows me to assign the appropriate GET, POST, PUT, DELETE and HEAD HTTP method permissions for the resource. Our clients are able to access the module table using GET requests via the Prestashop web services, but PUT does not seem to work at all.


Prestashop developer documentation in terms of web service implementation seems non-existent, besides a few guides on how to use the existing core web services.


I need to add some business rules to the update method for when we receive PUT requests from our clients. So trying to add an updateWs method to my model class


Some of the core Prestashop model classes that extend ObjectModel include an objectMethodsmember inside their $webservicesParameters array, which points to a method in the model class.



class SomeModel extends ObjectModel

    //...

    protected $webserviceParameters = array(
        'objectMethods' => array(
            'add' => 'addWs',
            'update' => 'updateWs'
        ),

    // ...

I tried the above technique in my model class, added the updateWs method like such:



public function updateWs()
{
    echo 'Check bizz rules, and save';
    exit;
}

The problem is, this code never gets hit? Any ideas what could be the issue?


I simply get a HTTP 200 response from Prestashop with the following in the body:



<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink></prestashop>
Edited by [email protected] (see edit history)
Link to comment
Share on other sites

×
×
  • Create New...