I'm working on a patch to allow users, through the UI, to choose between GET/POST/PUT/DELETE http methods. This is already available for developper, just not implemented in UI.

I need it on an important project at work, so I've worked on this patch and I commit it :
- add a "
" in the Operation setting UI
- make it available only on REST web services
- save it in $operation->type

It's my first patch on a project, so please tell me if I'm doing something wrong ;)

Comments

ncellier’s picture

StatusFileSize
new1.6 KB

And here is the patch.

I realize there is at least one more change to do : when a web service is changed from rest to soap, reset all the $operation->type values

klausi’s picture

Status: Patch (to be ported) » Needs work

Yay, good idea!

--- a/wsclient_ui/wsclient_ui.inc
+++ b/wsclient_ui/wsclient_ui.inc

REST specific stuff should go into the wsclient_rest.module. Use hook_form_FORM_ID_alter() there.

+++ b/wsclient_ui/wsclient_ui.inc
@@ -339,6 +354,9 @@ function wsclient_ui_more_submit($form, &$form_state) {
+  ¶

there should be no trailing spaces.

farald’s picture

How's the patching going on this? Somebody writing or shall I?

klausi’s picture

Assigned: ncellier » Unassigned

This looks inactive, so you are good to go. Just committed #1413344: incorporate formAlter() methods and random improvements , so that may help you.

farald’s picture

Ok, Ill have a look into it.

ezeedub’s picture

This is just what I was looking for. Nice module all!

I had some trouble applying the patch (2nd hunk failed). Here's a new one.

Now when I save an operation with HTTP Method "GET" (as well as the other methods), I get the following error:

Warning: Invalid argument supplied for foreach() in element_children() (line 6244 of /home/ed/workspace/my_project/drupal/includes/common.inc). Backtrace:
element_children(NULL) wsclient_ui.inc:700
wsclient_ui_validate_parameters(Array, Array, Array) form.inc:1379
_form_validate(Array, Array) form.inc:1265
_form_validate(Array, Array, 'wsclient_ui_operation') form.inc:1108
drupal_validate_form('wsclient_ui_operation', Array, Array) form.inc:835
drupal_process_form('wsclient_ui_operation', Array, Array) form.inc:366
drupal_build_form('wsclient_ui_operation', Array) form.inc:123
drupal_get_form('wsclient_ui_operation', Object, Array, 'edit') 
call_user_func_array('drupal_get_form', Array) menu.inc:517
menu_execute_active_handler() index.php:23

I dont' have time atm to drill down further, but I thought this might be of use...

ezeedub’s picture

And here's the patch.

muffinzap’s picture

Status: Needs work » Needs review
StatusFileSize
new2.49 KB

Hi, last patch works great, but has a problem with the file paths. Patches must be generated from the module's folder.
Olso I made an Improvement for compilance with the services module, since the services module needs to get the post fields in the $data array, and not in the $parameters one.

klausi’s picture

Status: Needs review » Needs work
+++ b/wsclient_rest/wsclient_rest.module
@@ -77,6 +77,10 @@ class WSClientRESTEndpoint extends WSClientEndpoint {
+    if ($type == 'POST') {
+      $data = array_merge((array) $data, $arguments);
+      $arguments = array();
+    }
     try {

Does not seem to be related to this issue?

+++ b/wsclient_rest/wsclient_rest.module
--- a/wsclient_ui/wsclient_ui.inc
+++ b/wsclient_ui/wsclient_ui.inc

+++ b/wsclient_ui/wsclient_ui.inc
+++ b/wsclient_ui/wsclient_ui.inc
@@ -332,6 +332,21 @@ function wsclient_ui_operation($form, &$form_state, $service, $operation, $op =

@@ -332,6 +332,21 @@ function wsclient_ui_operation($form, &$form_state, $service, $operation, $op =
     '#element_validate' => array('wsclient_ui_operation_name_validate'),
     '#weight' => -10,
   );

This is a REST specific parameter, so it does not make sense for SOAP services or others. This should be added by wsclient_rest module.

+++ b/wsclient_ui/wsclient_ui.inc
@@ -332,6 +332,21 @@ function wsclient_ui_operation($form, &$form_state, $service, $operation, $op =
+        '#description' => t('Specify the variables transmission method'),

Variables transmission method? Better use "Specify the HTTP request method used for this operation"?

PatchRanger’s picture

Status: Needs work » Needs review
StatusFileSize
new2.2 KB

Re-rolled given #9.
Please note: the patch is git-aware (i.e., was made using git format-patch), so it should be applied using git am. See https://drupal.org/node/1146430 for more details.

klausi’s picture

Status: Needs review » Needs work
+++ b/wsclient_rest/wsclient_rest.module
@@ -77,6 +77,11 @@ class WSClientRESTEndpoint extends WSClientEndpoint {
+    // Services module compliance: post fields should be in the $data array
+    // instead of $arguments.
+    if ($type == 'POST') {
+      $data = array_merge((array) $data, $arguments);
+    }

This is still here, does not belong in the patch.

PatchRanger’s picture

Status: Needs work » Needs review
StatusFileSize
new1.7 KB

Re-rolled given #11.

robloach’s picture

Status: Needs review » Reviewed & tested by the community
klausi’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.