diff --git a/sites/all/modules/contrib/wsclient/wsclient.inc b/sites/all/modules/contrib/wsclient/wsclient.inc
index 4040b06..9cb273c 100644
--- a/sites/all/modules/contrib/wsclient/wsclient.inc
+++ b/sites/all/modules/contrib/wsclient/wsclient.inc
@@ -157,6 +157,13 @@ class WSClientServiceDescription extends Entity {
  */
 interface WSClientEndpointInterface {
 
+  // no debug
+  const DEBUG_NONE = 0;
+  // write debug messages via watchdog function
+  const DEBUG_WATCHDOG = 1;
+  // write debug messages via watchdog and dsm functions
+  const DEBUG_DEVEL = 2;
+
   public function __construct(WSClientServiceDescription $service);
 
   /**
@@ -189,6 +196,15 @@ interface WSClientEndpointInterface {
    */
   public function clearCache();
 
+  /**
+   * Write trace debug message.
+   *
+   * @param string $data
+   *   The debug message.
+   *
+   */
+  public function debug($message = NULL, $level = self::DEBUG_NONE);
+
 }
 
 /**
@@ -219,6 +235,22 @@ abstract class WSClientEndpoint implements WSClientEndpointInterface {
   public function clearCache() {
     unset($this->client);
   }
+
+  public function debug($message = NULL, $level = WSClientEndpointInterface::DEBUG_NONE) {
+    if ($level == WSClientEndpointInterface::DEBUG_NONE || is_null($message)) {
+      return;
+    }
+
+    if ($level >= WSClientEndpointInterface::DEBUG_WATCHDOG) {
+      watchdog('wsclint', 'DEBUG: <pre>!message</pre>', array(
+        '!message' => print_r($message, TRUE),
+      ));
+    }
+
+    if ($level >= WSClientEndpointInterface::DEBUG_DEVEL && module_exists('devel')) {
+      dsm($message, 'wsclint');
+    }
+  }
 }
 
 /**
diff --git a/sites/all/modules/contrib/wsclient/wsclient_rest/wsclient_rest.module b/sites/all/modules/contrib/wsclient/wsclient_rest/wsclient_rest.module
index 621a417..20cd7a0 100644
--- a/sites/all/modules/contrib/wsclient/wsclient_rest/wsclient_rest.module
+++ b/sites/all/modules/contrib/wsclient/wsclient_rest/wsclient_rest.module
@@ -104,6 +104,18 @@ class WSClientRESTEndpoint extends WSClientEndpoint {
         'parameters' => $arguments,
         'data' => $data,
       )));
+
+      // Compose a debug message.
+      $message['request'] = array(
+        'uri' => $this->service->url . $operation_url,
+        'method' => $type,
+        'parameters' => $arguments,
+        'data' => $data,
+      );
+      $message['response']['header'] = $client->lastResponse->headers;
+      $message['response']['packet'] = $client->lastResponse->body;
+      $this->debug($message);
+
       return $response;
     }
     catch (HttpClientException $e) {
@@ -138,6 +150,18 @@ class WSClientRESTEndpoint extends WSClientEndpoint {
     }
   }
 
+  /**
+   * Write trace debug message.
+   *
+   * @param string $data
+   *   The debug message.
+   *
+   */
+  public function debug($message = NULL, $level = WSClientEndpointInterface::DEBUG_NONE) {
+    $debug_level = isset($this->service->settings['debug']) ? $this->service->settings['debug'] : 0;
+    parent::debug($message, $debug_level);
+  }
+
 }
 
 /**
diff --git a/sites/all/modules/contrib/wsclient/wsclient_soap/wsclient_soap.module b/sites/all/modules/contrib/wsclient/wsclient_soap/wsclient_soap.module
index 1afc8e2..c72cc56 100644
--- a/sites/all/modules/contrib/wsclient/wsclient_soap/wsclient_soap.module
+++ b/sites/all/modules/contrib/wsclient/wsclient_soap/wsclient_soap.module
@@ -33,6 +33,9 @@ class WSClientSOAPEndpoint extends WSClientEndpoint {
       if (!empty($this->service->settings['options'])) {
         $options += $this->service->settings['options'];
       }
+      if(!empty($this->service->settings['debug'])) {
+        $options['trace'] = TRUE;
+      }
       try {
         $this->client = new SOAPClient($this->url, $options);
       }
@@ -76,12 +79,32 @@ class WSClientSOAPEndpoint extends WSClientEndpoint {
     $client = $this->client();
     try {
       $response = $client->__soapCall($operation, $arguments);
+
+      // Compose a debug message.
+      $message['request']['header'] = $client->__getLastRequestHeaders();
+      $message['request']['packet'] = htmlspecialchars($client->__getLastRequest());
+      $message['response']['header'] = $client->__getLastResponseHeaders();
+      $message['response']['packet'] = htmlspecialchars($client->__getLastResponse());
+      $this->debug($message);
+
       return $response;
     }
     catch (SoapFault $e) {
       throw new WSClientException('Error invoking the SOAP service %name, operation %operation: %error', array('%name' => $this->service->label, '%operation' => $operation, '%error' => $e->getMessage()));
     }
   }
+
+  /**
+   * Write trace debug message.
+   *
+   * @param string $data
+   *   The debug message.
+   *
+   */
+  public function debug($message = NULL, $level = WSClientEndpointInterface::DEBUG_NONE) {
+    $debug_level = isset($this->service->settings['debug']) ? $this->service->settings['debug'] : 0;
+    parent::debug($message, $debug_level);
+  }
 }
 
 /**
diff --git a/sites/all/modules/contrib/wsclient/wsclient_ui/wsclient_ui.inc b/sites/all/modules/contrib/wsclient/wsclient_ui/wsclient_ui.inc
index 0df37be..940c0e1 100644
--- a/sites/all/modules/contrib/wsclient/wsclient_ui/wsclient_ui.inc
+++ b/sites/all/modules/contrib/wsclient/wsclient_ui/wsclient_ui.inc
@@ -90,6 +90,7 @@ function wsclient_service_form($form, &$form_state, $service, $op = 'edit') {
     $service->label .= ' (cloned)';
     $service->name .= '_clone';
   }
+
   $type_info = wsclient_get_types();
   if (empty($type_info)) {
     drupal_set_message(t('No service types were found, please enable a module that provides a service type.'), 'warning');
@@ -134,6 +135,17 @@ function wsclient_service_form($form, &$form_state, $service, $op = 'edit') {
     '#required' => TRUE,
     '#description' => t('The type of the web service.'),
   );
+  $form['debug'] = array(
+    '#type' => 'radios',
+    '#title' => 'Debug',
+    '#default_value' => isset($service->settings['debug']) ? $service->settings['debug'] : 0,
+    '#options' => array(
+      0 => t('Disable'),
+      1 => t('Enables logging with watchdog'),
+      2 => t('Enables logging with watchdog and dsm - requires devel module'),
+     ),
+    '#description' => t('Enables debug logging. Do not use in production.'),
+);
   if ($op == 'edit') {
     // Operations of the web service in a table
     $rows = array();
@@ -291,7 +303,7 @@ function wsclient_service_form_submit($form, &$form_state) {
       }
     }
   }
-
+  $service->settings['debug'] = $form_state['values']['debug'];
   $service->save();
   drupal_set_message(t('Web service description %service has been saved.', array('%service' => $service->label)));
   if ($form_state['op'] == 'add') {
