diff -ruN pear/SOAP/Base.php 1.0/SOAP/Base.php
--- pear/SOAP/Base.php 2005-05-04 23:33:51.000000000 +0200
+++ 1.0/SOAP/Base.php 2005-05-04 23:52:17.000000000 +0200
@@ -945,7 +945,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 = "\r\n$header_xml\r\n\r\n";
}
diff -ruN pear/SOAP/CVS/Entries 1.0/SOAP/CVS/Entries
--- pear/SOAP/CVS/Entries 2005-05-04 23:33:51.000000000 +0200
+++ 1.0/SOAP/CVS/Entries 2005-05-04 23:52:17.000000000 +0200
@@ -8,12 +8,12 @@
D/test////
D/tests////
D/tools////
-/Base.php/1.48/Wed May 4 21:33:51 2005//
-/Client.php/1.72/Wed May 4 21:33:51 2005//
-/Fault.php/1.16/Wed May 4 21:33:51 2005//
-/Parser.php/1.36/Wed May 4 21:33:51 2005//
-/Server.php/1.52/Wed May 4 21:33:51 2005//
-/Transport.php/1.25/Wed May 4 21:33:51 2005//
-/Value.php/1.39/Wed May 4 21:33:51 2005//
-/WSDL.php/1.76/Wed May 4 21:33:51 2005//
-/package.xml/1.57/Wed May 4 21:33:51 2005//
+/Base.php/1.48/Result of merge//
+/Client.php/1.72/Wed May 4 21:52:17 2005//
+/Fault.php/1.16/Wed May 4 21:52:17 2005//
+/Parser.php/1.36/Wed May 4 21:52:17 2005//
+/Server.php/1.52/Result of merge+Wed May 4 21:52:17 2005//
+/Transport.php/1.25/Wed May 4 21:52:17 2005//
+/Value.php/1.39/Wed May 4 21:52:17 2005//
+/WSDL.php/1.76/Wed May 4 21:52:17 2005//
+/package.xml/1.57/Wed May 4 21:52:17 2005//
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 @@
+ |
+// +----------------------------------------------------------------------+
+
+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/CVS/Entries 1.0/SOAP/Server/CVS/Entries
--- pear/SOAP/Server/CVS/Entries 2005-05-04 23:33:51.000000000 +0200
+++ 1.0/SOAP/Server/CVS/Entries 2005-05-04 23:52:18.000000000 +0200
@@ -1,4 +1,4 @@
-/Email.php/1.14/Wed May 4 21:33:51 2005//
-/Email_Gateway.php/1.13/Wed May 4 21:33:51 2005//
-/TCP.php/1.5/Wed May 4 21:33:51 2005//
+/Email.php/1.14/Wed May 4 21:52:17 2005//
+/Email_Gateway.php/1.13/Wed May 4 21:52:18 2005//
+/TCP.php/1.5/Wed May 4 21:52:18 2005//
D
diff -ruN pear/SOAP/Server.php 1.0/SOAP/Server.php
--- pear/SOAP/Server.php 2005-05-04 23:33:51.000000000 +0200
+++ 1.0/SOAP/Server.php 2005-05-05 00:00:57.000000000 +0200
@@ -16,7 +16,9 @@
// | Authors: Shane Caraveo Port to PEAR and more |
// | Authors: Dietrich Ayala Original Author |
// +----------------------------------------------------------------------+
-//
+// | Added support for new class which correct handles RPC response |
+// | Michael Rasmussen |
+// +----------------------------------------------------------------------+
// $Id: Server.php,v 1.52 2005/05/03 21:12:43 chagenbu 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;
@@ -188,37 +191,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) {
@@ -323,7 +330,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);
@@ -445,16 +452,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)