function xmlrpc_example_client_add_submit

Same name in other branches
  1. 7.x-1.x xmlrpc_example/xmlrpc_example.module \xmlrpc_example_client_add_submit()

Submit: query the xmlrpc endpoint for the method xmlrpc_example.add and report the result.

_state

Parameters

$form:

See also

xmlrpc()

xmlrpc_errno()

xmlrpc_error_msg()

Related topics

1 string reference to 'xmlrpc_example_client_add_submit'
xmlrpc_example_client_form in xmlrpc_example/xmlrpc_example.module
Present a form that makes use of xmlrpc services to add or subtract.

File

xmlrpc_example/xmlrpc_example.module, line 264

Code

function xmlrpc_example_client_add_submit($form, &$form_state) {
    // First define the endpoint of the xmlrcp service, in this case is our
    // own server.
    $server = url($GLOBALS['base_url'] . "/xmlrpc.php");
    // Then we should pass the method and the arguments to the xmlrpc client.
    // Make the xmlrpc request and process the results.
    $result = xmlrpc($server, 'xmlrpc_example.add', (int) $form_state['values']['num1'], (int) $form_state['values']['num2']);
    if ($result === FALSE) {
        drupal_set_message(t("Error return from xmlrpc(): Error: @errno, Message: @message", array(
            '@errno' => xmlrpc_errno(),
            '@message' => xmlrpc_error_msg(),
        )));
    }
    else {
        drupal_set_message(t("The XMLRPC server returned this response: @response", array(
            '@response' => print_r($result, TRUE),
        )));
    }
}