diff --git a/wsclient.inc b/wsclient.inc
index 40d4218..f0c346a 100644
--- a/wsclient.inc
+++ b/wsclient.inc
@@ -166,6 +166,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);
 
   /**
@@ -198,6 +205,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);
+
 }
 
 /**
@@ -228,6 +244,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('wsclient', 'DEBUG: <pre>!message</pre>', array(
+        '!message' => print_r($message, TRUE),
+      ));
+    }
+
+    if ($level >= WSClientEndpointInterface::DEBUG_DEVEL && module_exists('devel')) {
+      dsm($message, 'wsclient');
+    }
+  }
 }
 
 /**
diff --git a/wsclient_rest/wsclient_rest.module b/wsclient_rest/wsclient_rest.module
index 621a417..e303f59 100644
--- a/wsclient_rest/wsclient_rest.module
+++ b/wsclient_rest/wsclient_rest.module
@@ -99,11 +99,28 @@ class WSClientRESTEndpoint extends WSClientEndpoint {
       unset($arguments[$operation['data']]);
     }
     try {
-      $response = $client->execute(new HttpClientRequest($this->service->url . $operation_url, array(
+      $timer_before = microtime(TRUE);
+      $request = new HttpClientRequest($this->service->url . $operation_url, array(
         'method' => $type,
         'parameters' => $arguments,
         'data' => $data,
-      )));
+      ));
+      $response = $client->execute($request);
+      $timer_duration = microtime(TRUE) - $timer_before;
+
+      // Compose a debug message.
+      $message['request']['header'] = $request->getHeaders();
+      $message['request']['packet'] = 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;
+      $message['timer'] = $timer_duration . ' seconds';
+      $this->debug($message);
+
       return $response;
     }
     catch (HttpClientException $e) {
@@ -138,6 +155,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/wsclient_soap/wsclient_soap.module b/wsclient_soap/wsclient_soap.module
index 1afc8e2..b0f42f1 100644
--- a/wsclient_soap/wsclient_soap.module
+++ b/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);
       }
@@ -75,13 +78,36 @@ class WSClientSOAPEndpoint extends WSClientEndpoint {
   public function call($operation, $arguments) {
     $client = $this->client();
     try {
+      $timer_before = microtime(TRUE);
       $response = $client->__soapCall($operation, $arguments);
+      $timer_duration = microtime(TRUE) - $timer_before;
+
+      // 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());
+      $message['timer'] = $timer_duration . ' seconds';
+      $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/wsclient_ui/wsclient_ui.inc b/wsclient_ui/wsclient_ui.inc
index 5ff296a..f320b99 100644
--- a/wsclient_ui/wsclient_ui.inc
+++ b/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') {
