diff -ruN pear/SOAP/Base.php 1.0/SOAP/Base.php
--- pear/SOAP/Base.php	2005-04-09 04:51:19.000000000 +0200
+++ 1.0/SOAP/Base.php	2005-05-04 18:17:11.000000000 +0200
@@ -914,7 +914,7 @@
         if ($headers) {
             $c = count($headers);
             for ($i = 0; $i < $c; $i++) {
-                $header_xml .= $headers[$i]->serialize($this);
+               $header_xml .= $headers[$i]->serialize($this);
             }
             $header_xml = "<SOAP-ENV:Header>\r\n$header_xml\r\n</SOAP-ENV:Header>\r\n";
         }
diff -ruN pear/SOAP/SendRPCMessage.php 1.0/SOAP/SendRPCMessage.php
--- pear/SOAP/SendRPCMessage.php	1970-01-01 01:00:00.000000000 +0100
+++ 1.0/SOAP/SendRPCMessage.php	2005-05-04 13:31:45.000000000 +0200
@@ -0,0 +1,140 @@
+<?php
+
+require_once 'PEAR.php';
+
+//
+// +----------------------------------------------------------------------+
+// | PHP Version 4                                                        |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2003 The PHP Group                                |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 2.02 of the PHP license,      |
+// | that is bundled with this package in the file LICENSE, and is        |
+// | available at through the world-wide-web at                           |
+// | http://www.php.net/license/2_02.txt.                                 |
+// | If you did not receive a copy of the PHP license and are unable to   |
+// | obtain it through the world-wide-web, please send a note to          |
+// | license@php.net so we can mail you a copy immediately.               |
+// +----------------------------------------------------------------------+
+// | Authors:  Michael Rasmussen <mir@datanom.net>   |
+// +----------------------------------------------------------------------+
+
+class SendRPCMessage {
+
+	/**
+	|*
+	|*@xmlData string: Holds the SOAP Body
+	|*@ns string: Holds the reference to the servers namespace
+	|*@namespace string: Holds the actual namespace
+	|*@name string: Name of the complex type
+	|*@collection: The name of the list
+	|*@response string: The name for the request response
+	|*@struct array: The elements and their datatypes
+	|*/
+	
+	var $xmlData;
+	var $ns;
+	var $namespace;
+	var $name;
+	var $collection;
+	var $response;
+	var $struct;
+	var $pearError;
+	
+	/**
+	|*@soap soapobject: The current soap object of the server
+	|*@data array: The actual response to return
+	|*/
+	
+	function SendRPCMessage($soap, $data) {
+		$this->pearError = null;
+		$this->response = $soap->methodname.'Response';
+		$this->getNS($soap, $soap->methodname);
+		if (! is_array($data)) {
+			$this->xmlData = "<$soap->methodname>" . $data . "</$soap->methodname>\n";
+		}
+		else {
+			$nolist = false;
+			foreach ($data as $item => $value) {
+				if (is_array($value)) {
+					if (!$nolist) {
+						$size = count($data);
+						$this->xmlData ="<$this->collection "
+							."xmlns:soap-enc=\"http://schemas.xmlsoap.org/soap/encoding/\"";
+						$this->xmlData .= " xsi:type=\"soap-enc:Array\" "
+							."soap-enc:arrayType=\"$this->ns:".$this->name."[".$size."]\">\n";
+						$nolist = true;
+					}
+					$this->xmlData .= "<$this->name xsi:type=\"$this->ns:$this->name\">\n";
+					foreach($value as $element => $itemValue)
+						$this->xmlData .= "<$element xsi:type=\"xsd:".$this->struct[$element]."\">$itemValue"
+						."</$element>\n";
+					$this->xmlData .= "</$this->name>\n";
+				}
+				else {
+					if (!$nolist)
+						$this->xmlData = "<$this->collection "
+							."xmlns:soap-enc=\"http://schemas.xmlsoap.org/soap/encoding/\">\n";
+					$this->xmlData .= "<$item xsi:type=\"xsd:".$this->struct[$item]."\">$value</$item>\n";
+					$nolist = true;
+				}
+			}
+			$this->xmlData .= "</$this->collection>\n";
+		}
+	}
+
+	function getNS($soap, $method) {
+		if (! is_object($soap)) {
+			$this->pearError =& PEAR::raiseError("Not a SOAP server object");
+		}
+		else if  (! isset($soap->dispatch_objects))
+			$this->pearError = PEAR::raiseError("No dispatch objects defined in server");		
+		else {
+			foreach ($soap->dispatch_objects as $tns => $serverobject) {
+				foreach ($serverobject as $server) {
+					foreach ($server->__dispatch_map as $messages) {
+						foreach ($messages as $message) {
+							if (isset ($message[$method.'Response']))  {
+								/* Handle faulty namespace generated by WSDL.php */
+								$pos = strpos($message[$method.'Response'], '{');
+								if ($pos === false)
+									$size = strlen($tns);
+								else
+									$size = strlen($tns) + 6;
+								$this->collection = substr($message[$method.'Response'], $size);
+							}
+						}
+					}
+					$thetype = $server->__typedef[$this->collection];
+					if (!substr($thetype[$this->collection], $size))
+						$this->name = $this->collection;
+					else
+						$this->name = substr($thetype[$this->collection], $size);
+					foreach ($server->__typedef as  $typename => $typedef) {
+						if ($typename == $this->name)
+							$this->struct = $typedef;
+					}
+				}
+			$this->ns = $soap->_wsdl->ns[$tns];	
+			$this->namespace = $tns;
+			}
+		}
+	}
+	
+	function getResponse() {
+		if ($this->pearError) {
+			$response = $this->pearError;
+		}
+		else {
+			if (! $this->ns)
+				$this->ns = "ns1";
+			$response = "<$this->ns:$this->response "
+				."xmlns:$this->ns=\"$this->namespace\" "
+				.'SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">'."\n";
+			$response .= $this->xmlData . "</$this->ns:$this->response>";
+		}
+		return $response;
+	}
+}
+
+?>
diff -ruN pear/SOAP/Server.php 1.0/SOAP/Server.php
--- pear/SOAP/Server.php	2005-04-02 13:16:11.000000000 +0200
+++ 1.0/SOAP/Server.php	2005-05-04 18:20:08.000000000 +0200
@@ -16,7 +16,9 @@
 // | Authors: Shane Caraveo <Shane@Caraveo.com>   Port to PEAR and more   |
 // | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author         |
 // +----------------------------------------------------------------------+
-//
+// | Added support for new class which correct handles RPC response  |
+// | Michael Rasmussen <mir@datanom.net>                                        |
+// +------------------------------------------------------------------------------------+
 // $Id: Server.php,v 1.51 2005/04/02 11:16:11 yunosh Exp $
 //
 
@@ -25,6 +27,7 @@
 require_once 'SOAP/Parser.php';
 require_once 'SOAP/Value.php';
 require_once 'SOAP/WSDL.php';
+require_once 'SOAP/SendRPCMessage.php';
 
 $soap_server_fault = null;
 
@@ -189,37 +192,41 @@
              * file. */
             $this->_raiseSoapFault('Invalid SOAP request, must be POST with content-type: text/xml, got: ' . (isset($headers['content-type']) ? $headers['content-type'] : 'Nothing!'), '', '', 'Server');
         }
-
+ 
         if (!$this->fault) {
             /* $response is a SOAP_Msg object. */
-            $soap_msg = $this->parseRequest($data, $attachments);
-
-            /* Handle Mime or DIME encoding. */
-            /* TODO: DIME decoding should move to the transport, do it here
-             * for now and for ease of getting it done. */
-            if (count($this->__attachments)) {
-                if ($useEncoding == 'Mime') {
-                    $soap_msg = $this->_makeMimeMessage($soap_msg);
-                } else {
-                    // default is dime
-                    $soap_msg = $this->_makeDIMEMessage($soap_msg);
-                    $header['Content-Type'] = 'application/dime';
-                }
-                if (PEAR::isError($soap_msg)) {
-                    return $this->raiseSoapFault($soap_msg);
-                }
-            }
-
-            if (is_array($soap_msg)) {
-                $response = $soap_msg['body'];
-                if (count($soap_msg['headers'])) {
-                    $header = $soap_msg['headers'];
-                }
-            } else {
-                $response = $soap_msg;
-            }
+            $soap_msg =& $this->parseRequest($data, $attachments);
+            if (PEAR::isError($soap_msg)) {
+                $this->_raiseSoapFault($soap_msg->message);
+            }
+			else {
+				/* Handle Mime or DIME encoding. */
+				/* TODO: DIME decoding should move to the transport, do it here
+				 * for now and for ease of getting it done. */
+				if (count($this->__attachments)) {
+					if ($useEncoding == 'Mime') {
+						$soap_msg = $this->_makeMimeMessage($soap_msg);
+					} else {
+						// default is dime
+						$soap_msg = $this->_makeDIMEMessage($soap_msg);
+						$header['Content-Type'] = 'application/dime';
+					}
+					if (PEAR::isError($soap_msg)) {
+						return $this->_raiseSoapFault($soap_msg);
+					}
+				}
+
+				if (is_array($soap_msg) ) {
+					$response = $soap_msg['body'];
+					if (count($soap_msg['headers'])) {
+						$header = $soap_msg['headers'];
+					}
+				} else {
+					$response = $soap_msg;
+				}
+			}
         }
-
+		
         /* Make distinction between the different SAPIs, running PHP as CGI or
          * as a module. */
         if (stristr(php_sapi_name(), 'cgi') === 0) {
@@ -324,7 +331,7 @@
         return $return_val;
     }
 
-    function parseRequest($data = '', $attachments = null)
+	function parseRequest($data = '', $attachments = null)
     {
         /* Parse response, get SOAP_Parser object. */
         $parser =& new SOAP_Parser($data, $this->xml_encoding, $attachments);
@@ -446,16 +453,26 @@
             /* Get the method result. */
             if (is_null($method_response)) {
                 $return_val = null;
-            } else {
-                $return_val = $this->buildResult($method_response, $this->return_type);
-            }
-
-            $qn =& new QName($this->methodname . 'Response', $this->method_namespace);
-            $methodValue =& new SOAP_Value($qn->fqn(), 'Struct', $return_val);
-        } else {
+            } 
+			else {
+				$response =& new SendRPCMessage($this, $method_response);
+				$methodValue = $response->getResponse();
+			} 
+		}
+		else {
             $methodValue =& $method_response;
         }
-        return $this->_makeEnvelope($methodValue, $header_results, $this->response_encoding);
+		if (PEAR::isError($methodValue)) {
+			return $methodValue;
+		}
+		else {
+			return $this->_makeEnvelope(
+				$methodValue,
+				$header_results,
+				$this->response_encoding,
+				array('input' => 'rpc')
+			);
+		}
     }
 
     function &__decodeRequest($request, $shift = false)
