XML-RPC

Description

Using XML-RPC remote call protocol to manipulate Plone site.

Introduction

Zope provides transparent XML-RPC support for any traversable object.

Example:

# URL to the object
target = 'http://localhost:8080/plone'

# Call remote method
path = xmlrpclib.ServerProxy(target).getPhysicalPath()

Warning

Zope object handles are not transferable across function call boundaries. Thus, you can only call functions with primitive arguments. If you need to call function with object arguments you need to create server side helper code first.

For more information see

  • transmogrifier.ploneremote

Authentication

The simplest way to authenticate the user for XML-RPC calls is to embed HTTP Basic Auth data to URL:

# URL to the object
target = 'http://admin:admin@localhost:8080/plone'

# Call remote method
path = xmlrpclib.ServerProxy(target).getPhysicalPath()

ZPublisher client

XML-RPC does not marshal objects reliable between remote calls. Getting the real remote object can be done with ZPublisher.Client.Object.

Note

This approach works only for Python clients and needs Zope libraries available at the client side.

Warning

Zope object handles are not transferable across function call boundaries. Thus, you can only call functions with primitive arguments. If you need to call function with object arguments you need to create server side helper code first.

Web Services API for Plone (wsapi4plone)

This is an add-on product exposes more methods available through Zope's XML-RPC api.

Importing an Image Using WSAPI

In the following example we retreive, from the 'Pictures' folder, an image called 'red-wine-glass.jpg', post it to a folder called 'ministries' and give it the name 'theimage'.

import os
from xmlrpclib import ServerProxy
from xmlrpclib import Binary

client = ServerProxy("http://username:password@localhost:8080/path/to/plone")

data = open(os.path.join('Pictures', 'red-wine-glass.jpg')).read()

myimage = {'ministries/theimage': [{'title': 'a beautiful wine glass', 'image':Binary(data)},'Image']}


output = client.get_object(client.post_object(myimage))

For more information see wsapi4plone.core add-on product adds XML-RPC operations support for Plone.




Edit this document

The source code of this file is hosted on GitHub. Everyone can update and fix errors in this document with few clicks - no downloads needed.

  1. Go to XML-RPC on GitHub.
  2. Press Fork and edit this file button.
  3. Edit file contents using GitHub's text editor in your web browserm
  4. Fill in the Commit message text box at the end of the page telling why you did the changes. Press Propose file change button next to it when done.
  5. On Send a pull request page you don't need to fill in text anymore. Just press Send pull request button.
  6. Your changes are now queued for review under project's Pull requests tab on Github.

For basic information about updating this manual and Sphinx format please see Writing and updating the manual guide.