function wsclient_ui_operation_submit in Web service client 7
Submit callback of operation form.
1 string reference to 'wsclient_ui_operation_submit'
- wsclient_ui_operation in wsclient_ui/
wsclient_ui.inc - Operation form.
File
- wsclient_ui/
wsclient_ui.inc, line 810 - WSClient UI - implements service description management and configuration screens.
Code
function wsclient_ui_operation_submit($form, &$form_state) {
$service = $form_state['service'];
$operation = $form_state['operation'];
$operation['label'] = $form_state['values']['label'];
$operation['parameter'] = array();
foreach ($form_state['values']['parameters']['items'] as $key => $item) {
if (!empty($item['name'])) {
// Unmap the data type if it is local to this service.
$unmapped_type = _wsclient_ui_unmap_type($item['type'], $service);
if ($item['multiple']) {
$operation['parameter'][$item['name']] = array(
'type' => 'list<' . $unmapped_type . '>',
);
}
else {
$operation['parameter'][$item['name']] = array(
'type' => $unmapped_type,
);
}
if ($item['default_value'] !== '') {
$operation['parameter'][$item['name']]['default value'] = $item['default_value'];
}
if (!$item['required']) {
$operation['parameter'][$item['name']]['optional'] = TRUE;
}
$operation['parameter'][$item['name']]['allow null'] = $item['allow_null'];
}
}
// SOAP 1.2 etc may also require additional headers.
if ($service->type == 'soap 1.2' && !empty($form_state['values']['headers'])) {
$operation['header'] = array();
foreach ($form_state['values']['headers']['items'] as $key => $item) {
if (!empty($item['name'])) {
$operation['header'][$item['name']] = $item;
}
}
}
if (!empty($form_state['values']['result_type'])) {
$unmapped_type = _wsclient_ui_unmap_type($form_state['values']['result_type'], $service);
$operation['result'] = array(
'type' => $unmapped_type,
'label' => isset($form_state['values']['result_label']) ? $form_state['values']['result_label'] : 'result',
);
if ($form_state['values']['result_multiple']) {
$operation['result']['type'] = 'list<' . $unmapped_type . '>';
}
}
unset($service->operations[$form_state['operation']['name']]);
$service->operations[$form_state['values']['name']] = $operation;
$service
->save();
drupal_set_message(t('Operation %operation has been saved.', array(
'%operation' => $operation['label'],
)));
$form_state['redirect'] = WSCLIENT_UI_PATH . '/manage/' . $service->name;
rules_clear_cache();
}