1) Install all modules including tester module
2) Go to admin/config/services/wsclient/manage/twitter_search/operation/search/test
3) Click execute query.
4) Note error message below:

An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /system/ajax
StatusText: OK
ResponseText:
Fatal error: Call to undefined method HttpClient::__getLastRequestHeaders() in /Users/brian-johnalford/Sites/acquia-drupal/sites/all/modules/wsclient/wsclient_tester/wsclient_tester.inc on line 143

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

thomashuang025’s picture

Maybe the Twitter example is based on restful, but __getLastRequestHeaders() is not the function from HttpClient but SoapClient.
So I simply change the code in wsclient_tester.inc to get request information from other way,and it works for me.. Hope my code could be helpful to u. ^_^

in wsclient_tester.inc
replace

$element['request']['header']['#markup'] = $service->endpoint()->client()->__getLastRequestHeaders();
  $element['request']['packet']['#markup'] = htmlspecialchars(wsclient_tester_prettify_xml($service->endpoint()->client()->__getLastRequest()));
  if (module_exists('devel')) {
    $element['request']['data']['#markup'] = kpr($args, 1);
  }

  $element['response']['header']['#markup'] = $service->endpoint()->client()->__getLastResponseHeaders();
  $element['response']['packet']['#markup'] = htmlspecialchars(wsclient_tester_prettify_xml($service->endpoint()->client()->__getLastResponse()));
  if (module_exists('devel')) {
    $element['response']['data']['#markup'] = kpr($response, 1);
  }

with

  if($service->type=='rest'){
    $operation = $service->operations[$operation['name']];
    foreach($args as $para_name=>$para_value){
      $parameters.=$para_name.'='.$para_value.'<br>';
    }
    $reqInfo = 'Uri:'.$service->url.$operation['url'].'<br>'.
    'Method:'.(isset($operation['type']) ? $operation['type'] : 'GET').'<br>'.
    'Parameter:'.$parameters;
    $element['request']['packet']['#markup'] = $reqInfo;
    $element['response']['header']['#markup'] = $service->endpoint()->client()->lastResponse->headers;
    $element['response']['packet']['#markup'] = $service->endpoint()->client()->lastResponse->body;

  }else if($service->type=='soap'){
    $element['request']['header']['#markup'] = $service->endpoint()->client()->__getLastRequestHeaders();
    $element['request']['packet']['#markup'] = htmlspecialchars(wsclient_tester_prettify_xml($service->endpoint()->client()->__getLastRequest()));
    $element['response']['header']['#markup'] = $service->endpoint()->client()->__getLastResponseHeaders();
    $element['response']['packet']['#markup'] = htmlspecialchars(wsclient_tester_prettify_xml($service->endpoint()->client()->__getLastResponse()));
  }
  
  if (module_exists('devel')) {
    $element['request']['data']['#markup'] = kpr($args, 1);
  }
  if (module_exists('devel')) {
    $element['response']['data']['#markup'] = kpr($response, 1);
  }
klausi’s picture

Yep that seems to be hardcoded to SOAP right now. @thomashuang025 can you provide a proper patch?

thomashuang025’s picture

my first patch..

PatchRanger’s picture

Title: AJAX error on Twitter example » AJAX error in 'Web service client Tester' each time after clicking 'Execute request'
Version: 7.x-1.0-beta2 » 7.x-1.x-dev
Status: Active » Needs review

@thomashuang025 Congratulations, Huang, your patch works, thanks, it does what it should: it kills the error.
I have some notes though:

  • + $args = $args===NULL? array():$args;
    Personally I would like to see it as
    + $args = (array) $args;
    or even merge it with previous line
    -  $args = $form_state['values']['parameters'];
    +  $args = (array) $form_state['values']['parameters'];
    

    - in my view it is neater.

  • Use Coder Review (part of Coder project) to make all changes matching Drupal coding standards.
  • Issue that got some patch should be moved to 'needs review' status. See Status settings for an issue for additional info.

Please re-roll the patch according to coding standards - and maintainers will have greater intention to commit your patch.
I have changed the version, because I confirm that this error occurs in the latest dev too.
Changing the title to clarify the issue: it is not specific bug with Twitter service - it is bug of tester tool.

dman’s picture

Title: AJAX error in 'Web service client Tester' each time after clicking 'Execute request' » AJAX error in 'Web service client Tester' each time after clicking 'Execute request' - add REST support as well as SOAP
Status: Needs review » Fixed

I too (when I slow down and think about it) would prefer to just go

$args = (array) $form_state['values']['parameters'];

as it does all that is needed here.

However, I'd had a patch to sort out just the array issue in dev since April
http://drupalcode.org/project/wsclient.git/commit/78b27847ee6cc8c444d112...
It's not fully graceful there either, I think it was just a quick fix at the time.

I do think that it would pay to support REST as well as SOAP though - that was just all I had to test on at the time, and it had not been tried.
I applied this patch - by hand due to the earlier conflict, and because there was the coding standards whitespace to sort out.

But with that done, Yes, it does a good job of working with REST as well as SOAP, so bravo! Thanks for putting the effort in there thomashuang025

In other news, and in the meantime, Twitter has gone and broken that service for us

{"errors": [{"message": "The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.", "code": 68}]}

But at least it shows communication happens.

I'll push this patch into -dev now.
Thanks thomashuang025 !

Status: Fixed » Closed (fixed)

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

sam452’s picture

Issue summary: View changes

It appears this is still an issue? Both the production version from two years ago, and the more current dev version still will not work with the REST examples, as well as the REST API I'm trying to use it for? What am I overlooking? thx, sam

sam452’s picture

It appears this is still an issue? Both the production version from two years ago, and the more current dev version still will not work with the REST examples, as well as the REST API I'm trying to use it for? What am I overlooking? thx, sam

dman’s picture

Which REST service are you having trouble with?
If you provide a link to a public service endpoint, then it can be looked at. If not, then it's hard to help.

The Twitter example that comes with the module is broken because twitter changed, and so that example should probably be replaced with another open service we can use for testing.

sam452’s picture

Yes, the Google AJAX example is using REST. Attempting to use the wclient tester on this service returns:

An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /system/ajax
StatusText: Internal Server Error
ResponseText:

The SOAP examples work fine. But REST is what I need, thx.