You are here

function wsclient_tester_operation_test in Web service client 7

FAPI form used to display the options and the results of calling a web service.

1 string reference to 'wsclient_tester_operation_test'
wsclient_tester_menu in wsclient_tester/wsclient_tester.module
Publish our testing UI and ajax callbacks.

File

wsclient_tester/wsclient_tester.inc, line 12
Utility functions for running the tester UI for web services.

Code

function wsclient_tester_operation_test($form, $form_state, $service, $operation) {
  $strings = array(
    '!service_label' => $service->label,
    '!operation_label' => $operation['label'],
  );
  drupal_set_title(t("Testing Web Service : !service_label : !operation_label()", $strings));
  $form = array();
  $form['uri'] = array(
    '#title' => 'Service URI',
    '#type' => 'textfield',
    '#disabled' => TRUE,
    '#value' => $service->url,
  );
  $form['parameters'] = array(
    '#title' => 'parameters',
    '#type' => 'container',
    '#tree' => TRUE,
    '#value' => t("Enter the parameters to the !operation_label service here. It's up to you to get the data types right. No type validation is done at this end, as it's a debugger to let you throw various errors at the web service and see how it responds.", $strings),
  );

  // Deal with complex types.
  // Each complex type may require its own mini-form for data entry,
  // and these may be nested.
  $datatypes = $service->datatypes;
  foreach ($operation['parameter'] as $param => $info) {
    $form['parameters'][$param] = wsclient_tester_data_entry_form($param, $info['type'], @$info['description'], @$form_state['values']['parameters'], $datatypes);
  }
  $form['execute'] = array(
    '#type' => 'submit',
    '#value' => 'Execute request',
    '#ajax' => array(
      'event' => 'click',
      'callback' => 'wsclient_tester_prepare_request_callback',
      'wrapper' => 'edit-transaction',
      'method' => 'replace',
      'effect' => 'fade',
    ),
  );

  // Set up result panes. Content for these usually gets filled in via ajax.
  $form['transaction'] = array(
    '#type' => 'fieldset',
    '#title' => 'Transaction',
    '#attributes' => array(
      'id' => 'edit-transaction',
    ),
  );
  $form['transaction']['request'] = array(
    '#type' => 'fieldset',
    '#title' => 'Request',
  );
  $form['transaction']['request']['header'] = array(
    '#markup' => 'Headers go here',
    '#prefix' => '<pre>',
    '#suffix' => '</pre>',
  );
  $form['transaction']['request']['packet'] = array(
    '#markup' => 'Packet goes here',
    '#prefix' => '<pre>',
    '#suffix' => '</pre>',
  );
  $form['transaction']['request']['data'] = array();
  $form['transaction']['response'] = array(
    '#type' => 'fieldset',
    '#title' => 'Response',
  );
  $form['transaction']['response']['header'] = array(
    '#markup' => 'ResponseHeaders go here',
    '#prefix' => '<pre>',
    '#suffix' => '</pre>',
  );
  $form['transaction']['response']['packet'] = array(
    '#markup' => 'ResponsePayload goes here',
    '#prefix' => '<pre>',
    '#suffix' => '</pre>',
  );
  $form['transaction']['response']['data'] = array();
  return $form;
}