diff --git a/soap_server.module b/soap_server.module
index e1507bb..e75332c 100644
--- a/soap_server.module
+++ b/soap_server.module
@@ -218,6 +218,7 @@ class ServicesSoapServer {
     }
     
     if ($endpoint->debug) {
+      watchdog('soap server', 'RAW REQUEST: '. _prettify_xml($this->getRawRequest()));
       watchdog('soap server', "METHOD_NAME:<pre>". print_r($method_name, TRUE)."</pre");
       watchdog('soap server', "ENDPOINT:<pre>". print_r($endpoint, TRUE)."</pre");
       watchdog('soap server', "ARGS:<pre>". print_r($args, TRUE)."</pre");
@@ -234,6 +235,19 @@ class ServicesSoapServer {
     }
     return $ret;
   }
+  
+  /**
+  * Get the raw XML sent as an HTTP SOAP request.
+  * 
+  * @return string 
+  *   Contents of HTTP POST body.
+  */
+  public function getRawRequest() {
+    if (!isset($GLOBALS['HTTP_RAW_POST_DATA'])) {
+      $GLOBALS['HTTP_RAW_POST_DATA'] = file_get_contents('php://input');
+    }
+    return $GLOBALS['HTTP_RAW_POST_DATA'];
+  }
 }
 
 /**
@@ -284,7 +298,7 @@ function soap_server_debug_client($endpoint, $node) {
   }
   $debug_output == array(
     'endpoint' => $endpoint,
-  	'node' => $node,
+    'node' => $node,
   );
   if (empty($endpoint)) {
     watchdog('soap_server', 'no endpoint obj in debug client', 'error');
@@ -327,7 +341,7 @@ function soap_server_debug_client($endpoint, $node) {
   } catch (Exception $e) {
     $debug_output['client'] = $e;
   }
-  dsm($debug_output);
+  dpm($debug_output);
   return t("done");
 }
 
@@ -339,15 +353,26 @@ function soap_server_debug_client($endpoint, $node) {
 function soap_server_debug_wsdl($endpoint) {
   $wsdl_content = soap_server_get_wsdl($endpoint);
   $wsdl_content = _soap_server_beautify_wsdl($wsdl_content);
+  return _prettify_xml($wsdl_content);
+}
+
+/**
+ * Format XML so it looks nice embedded in a webpage for display to the user.
+ * 
+ * @param string $xml
+ *   Raw XML to format.
+ * @return string 
+ *   Formatted, htmlencoded XML string.
+ */
+function _prettify_xml($xml) {
   if (module_exists('geshifilter')) {
-    $geshi_inc = drupal_get_path('module', 'geshifilter') .'/geshifilter.pages.inc';
-    require_once $geshi_inc;
-    $wsdl_content = geshifilter_geshi_process($wsdl_content, 'xml', TRUE);
+    module_load_include('inc', 'geshifilter', 'geshifilter.pages');
+    $xml = geshifilter_geshi_process($xml, 'xml', TRUE);
   }
   else {
-    $wsdl_content = "<code>". htmlspecialchars($wsdl_content) ."</code>";
+    $xml = "<code>". htmlspecialchars($xml) ."</code>";
   }
-  return $wsdl_content;
+  return $xml;
 }
 
 /**
@@ -356,7 +381,7 @@ function soap_server_debug_wsdl($endpoint) {
  * WARNING: This is NOT a general XML formatter because it will remove whitespace
  * between tags and in CDATA blocks
  * 
- * @param unknown_type $xml
+ * @param string $xml
  */
 function _soap_server_beautify_wsdl($xml) { 
   // remove whitespace between tags
@@ -373,10 +398,8 @@ function _soap_server_beautify_wsdl($xml) {
   $matches    = array(); // returns from preg_matches()
   
   // scan each line and adjust indent based on opening/closing tags
-  while ($token !== false) : 
-  
+  while ($token !== false) {  
     // test for the various tag states
-    
     // 1. open and closing tags on same line - no change
     if (preg_match('/.+<\/\w[^>]*>$/', $token, $matches)) : 
       $indent=0;
@@ -396,7 +419,7 @@ function _soap_server_beautify_wsdl($xml) {
     $result .= $line . "\n"; // add to the cumulative result, with linefeed
     $token   = strtok("\n"); // get the next token
     $pad    += $indent; // update the pad size for subsequent lines    
-  endwhile; 
+  }
   
   return $result;
 }
