Comparison of Web-service client modules

There are several modules in Drupal that act as Web-service clients. Ideally, we'd only have one, but this page attempts to point them out and highlight some differences. At some point, perhaps for Drupal 8, we'll be able to merge all of these.

Feed Import - import multiple XML files with xinclude

Sometimes you have to import two or more xml files in the same way. There are several possibilities: creating a feed configuration for every xml file, creating a PHP function that uses Feed Import API or,
you can take a different approach by using xml xinclude.

Why? Because you'll have to maintain just one feed configuration and you can do this only from UI.
When? Usually when the xml files have the same structure.
How? Pretty simple, using xml XInclude.

Serialization API in Drupal 8

Drupal 8 can output JSON and XML versions of data using the Serialization API. Modules can add new serialization formats, as core's HAL (#1924854: [META] Hypertext Application Language (HAL) support) module will.

Serializing data

To serialize data, get the serializer from the container.

RESTful Web Services

RESTWS exposes Drupal resources (e.g. entities) as RESTful web services. The module makes use of the Entity API and the information about entity properties (provided via hook_entity_property_info()) to provide resource representations.

It aims to be fully compliant to the REST principles.

Installing the Module

  • Copy the whole restws directory to your modules directory (e.g. DRUPAL_ROOT/sites/all/modules) and activate the RESTful Web Services module.
  • Use Drush commands: drush dl restws & drush en restws
  • There is no user interface to configure.

Usage / Testing

To obtain the JSON representation of an entity use your browser to visit:<entity type name>/<entity id>.json
For example: or would resolve as a JSON dump to client. There are no "service endpoints" to configure as resources are just available at uniform paths like "node/1", "user/1". One can use a client in the form of a browser plugin to test out the different CRUD functions.


Subscribe with RSS Subscribe to RSS - xml