You are here

public function ServicesClientConnectionXmlrpcServer::prepareRequest in Services Client 7.2

Same name and namespace in other branches
  1. 7 services_client_connection/plugins/ServicesClientConnectionXmlrpcServer.inc \ServicesClientConnectionXmlrpcServer::prepareRequest()

Allows module to alter data in process of request

Parameters

ServicesClientConnectionHttpRequest $request:

Overrides ServicesClientConnectionPlugin::prepareRequest

File

services_client_connection/plugins/ServicesClientConnectionXmlrpcServer.inc, line 17
XMLRPC server

Class

ServicesClientConnectionXmlrpcServer
@file XMLRPC server

Code

public function prepareRequest(ServicesClientConnectionHttpRequest &$request) {
  parent::prepareRequest($request);
  $this
    ->includeXmlrpcLibrary();

  // No special changes to URL
  $request->url = $this->connection->endpoint;

  // All xml-rpc calls are post
  $request->http_method = 'POST';
  $request->http_headers['Content-Type'] = 'text/xml';
  $method = $request->resource . '.' . $request->action;
  if ($request->id) {
    $data = $request->data;
    $request->data = array(
      'id' => $request->id,
    );
    if (!empty($data)) {
      $request->data += array(
        $data,
      );
    }
  }
  $xml_request = xmlrpc_request($method, $request->data);
  $request->data = $xml_request->xml;
}