cvs: pear /SOAP Base.php Client.php Disco.php Fault.php Server.php Value.php WSDL.php /SOAP/Transport SMTP.php
| From: | Lukas Smith | Date: | Tue, 25 Sep 2007 21:07:01 +0000 |
| Subject: | cvs: pear /SOAP Base.php Client.php Disco.php Fault.php Server.php Value.php WSDL.php /SOAP/Transport SMTP.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-48678@lists.php.net to get a copy of this message | ||
lsmith Tue Sep 25 21:07:01 2007 UTC
Modified files:
/pear/SOAP Server.php WSDL.php Value.php Disco.php Base.php
Client.php Fault.php
/pear/SOAP/Transport SMTP.php
Log:
- added support for arbitrary SOAP-ENV and SOAP-ENC alternative namespace prefixes via the static
methods SOAP_BASE::setSOAPENVPrefix() and SOAP_BASE::setSOAPENCPrefix()
- added new options:
* soap_encoding (makes it possible to not base64 encode the SOAP message when using MIME
encoding)
* keep_arrays_flat (makes it possible to simply use the same tag name multiple times when passing
in an array in literal mode)
* no_type_prefix (supress adding of the namespace prefix)
- add support for attributes for file attachments
- one of the results of this patch is that options are propagated more (from the client to all
values generated by the client and among special values up to the parent soap value class)
http://cvs.php.net/viewvc.cgi/pear/SOAP/Server.php?r1=1.76&r2=1.77&diff_format=u Index: pear/SOAP/Server.php diff -u pear/SOAP/Server.php:1.76 pear/SOAP/Server.php:1.77 --- pear/SOAP/Server.php:1.76 Sun Feb 25 12:34:00 2007 +++ pear/SOAP/Server.php Tue Sep 25 21:07:00 2007 @@ -543,7 +543,7 @@ } if (is_array($requestArray)) { if (isset($requestArray['faultcode']) || - isset($requestArray['SOAP-ENV:faultcode'])) { + isset($requestArray[SOAP_BASE::setSOAPENVPrefix().':faultcode'])) { $faultcode = $faultstring = $faultdetail = $faultactor = ''; foreach ($requestArray as $k => $v) { if (stristr($k, 'faultcode')) { http://cvs.php.net/viewvc.cgi/pear/SOAP/WSDL.php?r1=1.100&r2=1.101&diff_format=u Index: pear/SOAP/WSDL.php diff -u pear/SOAP/WSDL.php:1.100 pear/SOAP/WSDL.php:1.101 --- pear/SOAP/WSDL.php:1.100 Sun Feb 25 12:34:00 2007 +++ pear/SOAP/WSDL.php Tue Sep 25 21:07:00 2007 @@ -2020,7 +2020,7 @@ $this->wsdl->namespaces['soap'] = SCHEMA_SOAP; // WSDL SOAP bindings $this->wsdl->namespaces[$this->tnsPrefix] = 'urn:' . $service_name; // Target namespace $this->wsdl->namespaces['xsd'] = array_search('xsd', $this->_namespaces); // XML Schema - $this->wsdl->namespaces['SOAP-ENC'] = array_search('SOAP-ENC', $this->_namespaces); // SOAP types + $this->wsdl->namespaces[SOAP_BASE::setSOAPENCPrefix()] = array_search(SOAP_BASE::setSOAPENCPrefix(), $this->_namespaces); // SOAP types // XXX Refactor $namespace/$ns for Shane :-) unset($this->wsdl->ns['urn:' . $service_name]); http://cvs.php.net/viewvc.cgi/pear/SOAP/Value.php?r1=1.46&r2=1.47&diff_format=u Index: pear/SOAP/Value.php diff -u pear/SOAP/Value.php:1.46 pear/SOAP/Value.php:1.47 --- pear/SOAP/Value.php:1.46 Fri Jan 26 00:18:17 2007 +++ pear/SOAP/Value.php Tue Sep 25 21:07:00 2007 @@ -82,9 +82,10 @@ * automatically if not set. * @param mixed $value Value to set. * @param array $attributes Attributes. + * @param array $options Options. */ function SOAP_Value($name = '', $type = false, $value = null, - $attributes = array()) + $attributes = array(), $options = array()) { // Detect type if not passed. $this->nqn = new QName($name); @@ -96,6 +97,7 @@ $this->type_namespace = $this->tqn->namespace; $this->value = $value; $this->attributes = $attributes; + $this->options = $options; } /** @@ -156,11 +158,11 @@ parent::SOAP_Value($name, $type, $value, $attributes); if (isset($actor)) { - $this->attributes['SOAP-ENV:actor'] = $actor; - } elseif (!isset($this->attributes['SOAP-ENV:actor'])) { - $this->attributes['SOAP-ENV:actor'] = 'http://schemas.xmlsoap.org/soap/actor/next'; + $this->attributes[SOAP_BASE::setSOAPENVPrefix().':actor'] = $actor; + } elseif (!isset($this->attributes[SOAP_BASE::setSOAPENVPrefix().':actor'])) { + $this->attributes[SOAP_BASE::setSOAPENVPrefix().':actor'] = 'http://schemas.xmlsoap.org/soap/actor/next'; } - $this->attributes['SOAP-ENV:mustUnderstand'] = (int)$mustunderstand; + $this->attributes[SOAP_BASE::setSOAPENVPrefix().':mustUnderstand'] = (int)$mustunderstand; } } @@ -183,9 +185,10 @@ * @param string $filename The attachment's file name. Ignored if $file * is provide. * @param string $file The attachment data. + * @param array $attributes Attributes. */ function SOAP_Attachment($name = '', $type = 'application/octet-stream', - $filename, $file = null) + $filename, $file = null, $attributes = null) { parent::SOAP_Value($name, null, null); @@ -198,7 +201,8 @@ $cid = md5(uniqid(time())); - $this->attributes['href'] = 'cid:' . $cid; + $this->attributes = $attributes; + $this->attributes['href'] = 'cid:' . $cid; $this->options['attachment'] = array('body' => $filedata, 'disposition' => $filename, http://cvs.php.net/viewvc.cgi/pear/SOAP/Disco.php?r1=1.18&r2=1.19&diff_format=u Index: pear/SOAP/Disco.php diff -u pear/SOAP/Disco.php:1.18 pear/SOAP/Disco.php:1.19 --- pear/SOAP/Disco.php:1.18 Sun Feb 25 12:34:00 2007 +++ pear/SOAP/Disco.php Tue Sep 25 21:07:00 2007 @@ -90,7 +90,7 @@ $flipped = array_flip($this->soap_server->_namespaces); $this->namespaces[$this->_service_ns] = 'tns'; $this->namespaces[$flipped['xsd']] = 'xsd'; - $this->namespaces[$flipped['SOAP-ENC']] = 'SOAP-ENC'; + $this->namespaces[$flipped[SOAP_BASE::setSOAPENCPrefix()]] = SOAP_BASE::setSOAPENCPrefix(); } // DEFINITIONS @@ -208,10 +208,10 @@ $el['attr']['type'] = $_vartypens . ':' . $_vartype; } else { $ctype['complexContent']['attr'] = ''; - $ctype['complexContent']['restriction']['attr']['base'] = 'SOAP-ENC:Array'; + $ctype['complexContent']['restriction']['attr']['base'] = SOAP_BASE::setSOAPENCPrefix().':Array'; foreach ($_vartype as $array_type) { list($_vartypens, $_vartype) = $this->_getTypeNs($array_type); - $ctype['complexContent']['restriction']['attribute']['attr']['ref'] = 'SOAP-ENC:arrayType'; + $ctype['complexContent']['restriction']['attribute']['attr']['ref'] = SOAP_BASE::setSOAPENCPrefix().':arrayType'; $ctype['complexContent']['restriction']['attribute']['attr']['wsdl:arrayType'] = $_vartypens . ':' . $_vartype . '[]'; } } http://cvs.php.net/viewvc.cgi/pear/SOAP/Base.php?r1=1.86&r2=1.87&diff_format=u Index: pear/SOAP/Base.php diff -u pear/SOAP/Base.php:1.86 pear/SOAP/Base.php:1.87 --- pear/SOAP/Base.php:1.86 Fri Jun 29 14:59:13 2007 +++ pear/SOAP/Base.php Tue Sep 25 21:07:00 2007 @@ -286,6 +286,46 @@ } /** + * Sets the SOAP-ENV prefix and returns the current value. + * + * @access public + * + * @param string SOAP-ENV prefix + * + * @return string current SOAP-ENV prefix. + */ + function setSOAPENVPrefix($prefix = null) + { + static $_soapenv_prefix; + if (!is_null($prefix)) { + $_soapenv_prefix = $prefix; + } elseif (is_null($_soapenv_prefix)) { + $_soapenv_prefix = 'SOAP-ENV'; + } + return $_soapenv_prefix; + } + + /** + * Sets the SOAP-ENC prefix and returns the current value. + * + * @access public + * + * @param string SOAP-ENC prefix + * + * @return string current SOAP-ENC prefix. + */ + function setSOAPENCPrefix($prefix = null) + { + static $_soapenv_prefix; + if (!is_null($prefix)) { + $_soapenv_prefix = $prefix; + } elseif (is_null($_soapenv_prefix)) { + $_soapenv_prefix = 'SOAP-ENC'; + } + return $_soapenv_prefix; + } + + /** * Sets the default namespace. * * @param string $namespace The default namespace. @@ -298,10 +338,10 @@ function _resetNamespaces() { $this->_namespaces = array( - 'http://schemas.xmlsoap.org/soap/envelope/' => 'SOAP-ENV', + 'http://schemas.xmlsoap.org/soap/envelope/' => SOAP_BASE::setSOAPENVPrefix(), 'http://www.w3.org/2001/XMLSchema' => 'xsd', 'http://www.w3.org/2001/XMLSchema-instance' => 'xsi', - 'http://schemas.xmlsoap.org/soap/encoding/' => 'SOAP-ENC'); + 'http://schemas.xmlsoap.org/soap/encoding/' => SOAP_BASE::setSOAPENCPrefix()); } /** @@ -402,10 +442,10 @@ // XXX get the members and serialize them instead // converting to an array is more overhead than we // should really do. - $xmlout_value .= $this->_serializeValue(get_object_vars($vars[$k]), $k, false, $this->_section5 ? null : $elNamespace); + $xmlout_value .= $this->_serializeValue(get_object_vars($vars[$k]), $k, false, $this->_section5 ? null : $elNamespace, null, $options); } } else { - $xmlout_value .= $this->_serializeValue($vars[$k], $k, false, $this->_section5 ? null : $elNamespace); + $xmlout_value .= $this->_serializeValue($vars[$k], $k, false, $this->_section5 ? null : $elNamespace, null, $options); } } } @@ -446,11 +486,15 @@ } else { $array_type = $this->_getType($array_val); $array_types[$array_type] = 1; - $xmlout_value .= $this->_serializeValue($array_val, 'item', $array_type, $this->_section5 ? null : $elNamespace); + if (empty($options['keep_arrays_flat'])) { + $xmlout_value .= $this->_serializeValue($array_val, 'item', $array_type, $this->_section5 ? null : $elNamespace, $options); + } else { + $xmlout_value .= $this->_serializeValue($array_val, $name, $array_type, $elNamespace, null, $options, $attributes); + } } } - $xmlout_offset = ' SOAP-ENC:offset="[0]"'; + $xmlout_offset = ' '.SOAP_BASE::setSOAPENCPrefix().':offset="[0]"'; if (!$arrayType) { $numtypes = count($array_types); if ($numtypes == 1) { @@ -483,7 +527,7 @@ } } - $xmlout_arrayType = ' SOAP-ENC:arrayType="' . $arrayType; + $xmlout_arrayType = ' '.SOAP_BASE::setSOAPENCPrefix().':arrayType="' . $arrayType; if ($array_depth != null) { for ($i = 0; $i < $array_depth; $i++) { $xmlout_arrayType .= '[]'; @@ -515,7 +559,10 @@ } if ($typeNamespace) { - $typePrefix = $this->_getNamespacePrefix($typeNamespace); + $typePrefix = false; + if (empty($options['no_type_prefix'])) { + $typePrefix = $this->_getNamespacePrefix($typeNamespace); + } if ($typePrefix) { $xmlout_type = "$typePrefix:$type"; } else { @@ -558,6 +605,8 @@ $xml = "\r\n<$xmlout_name$xmlout_type$xmlns$xmlout_arrayType" . "$xmlout_offset$xml_attr>$xmlout_value</$xmlout_name>"; } + } elseif ($type == 'Array' && !empty($options['keep_arrays_flat'])) { + $xml = $xmlout_value; } else { if (is_null($xmlout_value)) { $xml = "\r\n<$xmlout_name$xmlns$xml_attr/>"; @@ -865,7 +914,7 @@ for ($i = 0; $i < $c; $i++) { $header_xml .= $headers[$i]->serialize($this); } - $header_xml = "<SOAP-ENV:Header>\r\n$header_xml\r\n</SOAP-ENV:Header>\r\n"; + $header_xml = "<".SOAP_BASE::setSOAPENVPrefix().":Header>\r\n$header_xml\r\n</".SOAP_BASE::setSOAPENVPrefix().":Header>\r\n"; } if (!isset($options['input']) || $options['input'] == 'parse') { @@ -880,7 +929,7 @@ } else { $smsg = $method; } - $body = "<SOAP-ENV:Body>\r\n" . $smsg . "\r\n</SOAP-ENV:Body>\r\n"; + $body = "<".SOAP_BASE::setSOAPENVPrefix().":Body>\r\n" . $smsg . "\r\n</".SOAP_BASE::setSOAPENVPrefix().":Body>\r\n"; foreach ($this->_namespaces as $k => $v) { $ns_string .= " xmlns:$v=\"$k\"\r\n"; @@ -894,15 +943,15 @@ * more granular level than we are dealing with here, so this does not * work for all services. */ $xml = "<?xml version=\"1.0\" encoding=\"$encoding\"?>\r\n\r\n". - "<SOAP-ENV:Envelope $ns_string". - ($this->_section5 ? ' SOAP-ENV:encodingStyle="' . SOAP_SCHEMA_ENCODING . '"' : ''). + "<".SOAP_BASE::setSOAPENVPrefix().":Envelope $ns_string". + ($this->_section5 ? ' '.SOAP_BASE::setSOAPENVPrefix().':encodingStyle="' . SOAP_SCHEMA_ENCODING . '"' : ''). ">\r\n". - "$header_xml$body</SOAP-ENV:Envelope>\r\n"; + "$header_xml$body</".SOAP_BASE::setSOAPENVPrefix().":Envelope>\r\n"; return $xml; } - function _makeMimeMessage($xml, $encoding = SOAP_DEFAULT_ENCODING) + function _makeMimeMessage($xml, $encoding = SOAP_DEFAULT_ENCODING, $soap_encoding = 'base64') { if (!@include_once 'Mail/mimePart.php') { return $this->_raiseSoapFault('MIME messages are unsupported, the Mail_Mime package is not installed'); @@ -916,7 +965,7 @@ // Add the xml part. $params['content_type'] = 'text/xml'; $params['charset'] = $encoding; - $params['encoding'] = 'base64'; + $params['encoding'] = $soap_encoding; $msg->addSubPart($xml, $params); // Add the attachements http://cvs.php.net/viewvc.cgi/pear/SOAP/Client.php?r1=1.90&r2=1.91&diff_format=u Index: pear/SOAP/Client.php diff -u pear/SOAP/Client.php:1.90 pear/SOAP/Client.php:1.91 --- pear/SOAP/Client.php:1.90 Wed Jun 27 13:28:02 2007 +++ pear/SOAP/Client.php Tue Sep 25 21:07:00 2007 @@ -531,7 +531,7 @@ $soapAction = false) { $this->fault = null; - $this->_options['input'] = 'parse'; + $this->_options['input'] = 'parse'; $this->_options['result'] = 'parse'; $this->_options['parameters'] = false; @@ -648,7 +648,7 @@ $this->_options['style'] = 'rpc'; $this->docparams = true; $mqname = new QName($method, $namespace); - $methodValue = new SOAP_Value($mqname->fqn(), 'Struct', $params); + $methodValue = new SOAP_Value($mqname->fqn(), 'Struct', $params, array(), $this->_options); $soap_msg = $this->makeEnvelope($methodValue, $this->headersOut, $this->_encoding, @@ -698,7 +698,8 @@ if ((isset($this->_options['attachments']) && $this->_options['attachments'] == 'Mime') || isset($this->_options['Mime'])) { - $soap_msg = $this->_makeMimeMessage($soap_msg, $this->_encoding); + $soap_encoding = isset($this->_options['soap_encoding']) ? $this->_options['soap_encoding'] : 'base64'; + $soap_msg = $this->_makeMimeMessage($soap_msg, $this->_encoding, $soap_encoding); } else { // default is dime $soap_msg = $this->_makeDIMEMessage($soap_msg, $this->_encoding); @@ -801,7 +802,7 @@ } if (is_array($returnArray)) { if (isset($returnArray['faultcode']) || - isset($returnArray['SOAP-ENV:faultcode'])) { + isset($returnArray[SOAP_BASE::setSOAPENVPrefix().':faultcode'])) { $faultcode = $faultstring = $faultdetail = $faultactor = ''; foreach ($returnArray as $k => $v) { if (stristr($k, 'faultcode')) $faultcode = $v; http://cvs.php.net/viewvc.cgi/pear/SOAP/Fault.php?r1=1.22&r2=1.23&diff_format=u Index: pear/SOAP/Fault.php diff -u pear/SOAP/Fault.php:1.22 pear/SOAP/Fault.php:1.23 --- pear/SOAP/Fault.php:1.22 Thu Jan 25 23:14:05 2007 +++ pear/SOAP/Fault.php Tue Sep 25 21:07:00 2007 @@ -75,7 +75,7 @@ { $msg = new SOAP_Base(); $params = array(); - $params[] = new SOAP_Value('faultcode', 'QName', 'SOAP-ENV:' . $this->code); + $params[] = new SOAP_Value('faultcode', 'QName', SOAP_BASE::setSOAPENVPrefix().':' . $this->code); $params[] = new SOAP_Value('faultstring', 'string', $this->message); $params[] = new SOAP_Value('faultactor', 'anyURI', $this->error_message_prefix); if (isset($this->backtrace)) { http://cvs.php.net/viewvc.cgi/pear/SOAP/Transport/SMTP.php?r1=1.28&r2=1.29&diff_format=u Index: pear/SOAP/Transport/SMTP.php diff -u pear/SOAP/Transport/SMTP.php:1.28 pear/SOAP/Transport/SMTP.php:1.29 --- pear/SOAP/Transport/SMTP.php:1.28 Sun Feb 25 12:34:00 2007 +++ pear/SOAP/Transport/SMTP.php Tue Sep 25 21:07:01 2007 @@ -151,7 +151,7 @@ if (!PEAR::isError($result)) { $val = new SOAP_Value('Message-ID', 'string', $headers['Message-ID']); } else { - $sval[] = new SOAP_Value('faultcode', 'QName', 'SOAP-ENV:Client'); + $sval[] = new SOAP_Value('faultcode', 'QName', SOAP_BASE::setSOAPENVPrefix().':Client'); $sval[] = new SOAP_Value('faultstring', 'string', "couldn't send SMTP message to {$this->urlparts['path']}"); $val = new SOAP_Value('Fault', 'Struct', $sval); }
http://cvs.php.net/viewvc.cgi/pear/SOAP/Server.php?r1=1.76&r2=1.77&diff_format=u Index: pear/SOAP/Server.php diff -u pear/SOAP/Server.php:1.76 pear/SOAP/Server.php:1.77 --- pear/SOAP/Server.php:1.76 Sun Feb 25 12:34:00 2007 +++ pear/SOAP/Server.php Tue Sep 25 21:07:00 2007 @@ -543,7 +543,7 @@ } if (is_array($requestArray)) { if (isset($requestArray['faultcode']) || - isset($requestArray['SOAP-ENV:faultcode'])) { + isset($requestArray[SOAP_BASE::setSOAPENVPrefix().':faultcode'])) { $faultcode = $faultstring = $faultdetail = $faultactor = ''; foreach ($requestArray as $k => $v) { if (stristr($k, 'faultcode')) { http://cvs.php.net/viewvc.cgi/pear/SOAP/WSDL.php?r1=1.100&r2=1.101&diff_format=u Index: pear/SOAP/WSDL.php diff -u pear/SOAP/WSDL.php:1.100 pear/SOAP/WSDL.php:1.101 --- pear/SOAP/WSDL.php:1.100 Sun Feb 25 12:34:00 2007 +++ pear/SOAP/WSDL.php Tue Sep 25 21:07:00 2007 @@ -2020,7 +2020,7 @@ $this->wsdl->namespaces['soap'] = SCHEMA_SOAP; // WSDL SOAP bindings $this->wsdl->namespaces[$this->tnsPrefix] = 'urn:' . $service_name; // Target namespace $this->wsdl->namespaces['xsd'] = array_search('xsd', $this->_namespaces); // XML Schema - $this->wsdl->namespaces['SOAP-ENC'] = array_search('SOAP-ENC', $this->_namespaces); // SOAP types + $this->wsdl->namespaces[SOAP_BASE::setSOAPENCPrefix()] = array_search(SOAP_BASE::setSOAPENCPrefix(), $this->_namespaces); // SOAP types // XXX Refactor $namespace/$ns for Shane :-) unset($this->wsdl->ns['urn:' . $service_name]); http://cvs.php.net/viewvc.cgi/pear/SOAP/Value.php?r1=1.46&r2=1.47&diff_format=u Index: pear/SOAP/Value.php diff -u pear/SOAP/Value.php:1.46 pear/SOAP/Value.php:1.47 --- pear/SOAP/Value.php:1.46 Fri Jan 26 00:18:17 2007 +++ pear/SOAP/Value.php Tue Sep 25 21:07:00 2007 @@ -82,9 +82,10 @@ * automatically if not set. * @param mixed $value Value to set. * @param array $attributes Attributes. + * @param array $options Options. */ function SOAP_Value($name = '', $type = false, $value = null, - $attributes = array()) + $attributes = array(), $options = array()) { // Detect type if not passed. $this->nqn = new QName($name); @@ -96,6 +97,7 @@ $this->type_namespace = $this->tqn->namespace; $this->value = $value; $this->attributes = $attributes; + $this->options = $options; } /** @@ -156,11 +158,11 @@ parent::SOAP_Value($name, $type, $value, $attributes); if (isset($actor)) { - $this->attributes['SOAP-ENV:actor'] = $actor; - } elseif (!isset($this->attributes['SOAP-ENV:actor'])) { - $this->attributes['SOAP-ENV:actor'] = 'http://schemas.xmlsoap.org/soap/actor/next'; + $this->attributes[SOAP_BASE::setSOAPENVPrefix().':actor'] = $actor; + } elseif (!isset($this->attributes[SOAP_BASE::setSOAPENVPrefix().':actor'])) { + $this->attributes[SOAP_BASE::setSOAPENVPrefix().':actor'] = 'http://schemas.xmlsoap.org/soap/actor/next'; } - $this->attributes['SOAP-ENV:mustUnderstand'] = (int)$mustunderstand; + $this->attributes[SOAP_BASE::setSOAPENVPrefix().':mustUnderstand'] = (int)$mustunderstand; } } @@ -183,9 +185,10 @@ * @param string $filename The attachment's file name. Ignored if $file * is provide. * @param string $file The attachment data. + * @param array $attributes Attributes. */ function SOAP_Attachment($name = '', $type = 'application/octet-stream', - $filename, $file = null) + $filename, $file = null, $attributes = null) { parent::SOAP_Value($name, null, null); @@ -198,7 +201,8 @@ $cid = md5(uniqid(time())); - $this->attributes['href'] = 'cid:' . $cid; + $this->attributes = $attributes; + $this->attributes['href'] = 'cid:' . $cid; $this->options['attachment'] = array('body' => $filedata, 'disposition' => $filename, http://cvs.php.net/viewvc.cgi/pear/SOAP/Disco.php?r1=1.18&r2=1.19&diff_format=u Index: pear/SOAP/Disco.php diff -u pear/SOAP/Disco.php:1.18 pear/SOAP/Disco.php:1.19 --- pear/SOAP/Disco.php:1.18 Sun Feb 25 12:34:00 2007 +++ pear/SOAP/Disco.php Tue Sep 25 21:07:00 2007 @@ -90,7 +90,7 @@ $flipped = array_flip($this->soap_server->_namespaces); $this->namespaces[$this->_service_ns] = 'tns'; $this->namespaces[$flipped['xsd']] = 'xsd'; - $this->namespaces[$flipped['SOAP-ENC']] = 'SOAP-ENC'; + $this->namespaces[$flipped[SOAP_BASE::setSOAPENCPrefix()]] = SOAP_BASE::setSOAPENCPrefix(); } // DEFINITIONS @@ -208,10 +208,10 @@ $el['attr']['type'] = $_vartypens . ':' . $_vartype; } else { $ctype['complexContent']['attr'] = ''; - $ctype['complexContent']['restriction']['attr']['base'] = 'SOAP-ENC:Array'; + $ctype['complexContent']['restriction']['attr']['base'] = SOAP_BASE::setSOAPENCPrefix().':Array'; foreach ($_vartype as $array_type) { list($_vartypens, $_vartype) = $this->_getTypeNs($array_type); - $ctype['complexContent']['restriction']['attribute']['attr']['ref'] = 'SOAP-ENC:arrayType'; + $ctype['complexContent']['restriction']['attribute']['attr']['ref'] = SOAP_BASE::setSOAPENCPrefix().':arrayType'; $ctype['complexContent']['restriction']['attribute']['attr']['wsdl:arrayType'] = $_vartypens . ':' . $_vartype . '[]'; } } http://cvs.php.net/viewvc.cgi/pear/SOAP/Base.php?r1=1.86&r2=1.87&diff_format=u Index: pear/SOAP/Base.php diff -u pear/SOAP/Base.php:1.86 pear/SOAP/Base.php:1.87 --- pear/SOAP/Base.php:1.86 Fri Jun 29 14:59:13 2007 +++ pear/SOAP/Base.php Tue Sep 25 21:07:00 2007 @@ -286,6 +286,46 @@ } /** + * Sets the SOAP-ENV prefix and returns the current value. + * + * @access public + * + * @param string SOAP-ENV prefix + * + * @return string current SOAP-ENV prefix. + */ + function setSOAPENVPrefix($prefix = null) + { + static $_soapenv_prefix; + if (!is_null($prefix)) { + $_soapenv_prefix = $prefix; + } elseif (is_null($_soapenv_prefix)) { + $_soapenv_prefix = 'SOAP-ENV'; + } + return $_soapenv_prefix; + } + + /** + * Sets the SOAP-ENC prefix and returns the current value. + * + * @access public + * + * @param string SOAP-ENC prefix + * + * @return string current SOAP-ENC prefix. + */ + function setSOAPENCPrefix($prefix = null) + { + static $_soapenv_prefix; + if (!is_null($prefix)) { + $_soapenv_prefix = $prefix; + } elseif (is_null($_soapenv_prefix)) { + $_soapenv_prefix = 'SOAP-ENC'; + } + return $_soapenv_prefix; + } + + /** * Sets the default namespace. * * @param string $namespace The default namespace. @@ -298,10 +338,10 @@ function _resetNamespaces() { $this->_namespaces = array( - 'http://schemas.xmlsoap.org/soap/envelope/' => 'SOAP-ENV', + 'http://schemas.xmlsoap.org/soap/envelope/' => SOAP_BASE::setSOAPENVPrefix(), 'http://www.w3.org/2001/XMLSchema' => 'xsd', 'http://www.w3.org/2001/XMLSchema-instance' => 'xsi', - 'http://schemas.xmlsoap.org/soap/encoding/' => 'SOAP-ENC'); + 'http://schemas.xmlsoap.org/soap/encoding/' => SOAP_BASE::setSOAPENCPrefix()); } /** @@ -402,10 +442,10 @@ // XXX get the members and serialize them instead // converting to an array is more overhead than we // should really do. - $xmlout_value .= $this->_serializeValue(get_object_vars($vars[$k]), $k, false, $this->_section5 ? null : $elNamespace); + $xmlout_value .= $this->_serializeValue(get_object_vars($vars[$k]), $k, false, $this->_section5 ? null : $elNamespace, null, $options); } } else { - $xmlout_value .= $this->_serializeValue($vars[$k], $k, false, $this->_section5 ? null : $elNamespace); + $xmlout_value .= $this->_serializeValue($vars[$k], $k, false, $this->_section5 ? null : $elNamespace, null, $options); } } } @@ -446,11 +486,15 @@ } else { $array_type = $this->_getType($array_val); $array_types[$array_type] = 1; - $xmlout_value .= $this->_serializeValue($array_val, 'item', $array_type, $this->_section5 ? null : $elNamespace); + if (empty($options['keep_arrays_flat'])) { + $xmlout_value .= $this->_serializeValue($array_val, 'item', $array_type, $this->_section5 ? null : $elNamespace, $options); + } else { + $xmlout_value .= $this->_serializeValue($array_val, $name, $array_type, $elNamespace, null, $options, $attributes); + } } } - $xmlout_offset = ' SOAP-ENC:offset="[0]"'; + $xmlout_offset = ' '.SOAP_BASE::setSOAPENCPrefix().':offset="[0]"'; if (!$arrayType) { $numtypes = count($array_types); if ($numtypes == 1) { @@ -483,7 +527,7 @@ } } - $xmlout_arrayType = ' SOAP-ENC:arrayType="' . $arrayType; + $xmlout_arrayType = ' '.SOAP_BASE::setSOAPENCPrefix().':arrayType="' . $arrayType; if ($array_depth != null) { for ($i = 0; $i < $array_depth; $i++) { $xmlout_arrayType .= '[]'; @@ -515,7 +559,10 @@ } if ($typeNamespace) { - $typePrefix = $this->_getNamespacePrefix($typeNamespace); + $typePrefix = false; + if (empty($options['no_type_prefix'])) { + $typePrefix = $this->_getNamespacePrefix($typeNamespace); + } if ($typePrefix) { $xmlout_type = "$typePrefix:$type"; } else { @@ -558,6 +605,8 @@ $xml = "\r\n<$xmlout_name$xmlout_type$xmlns$xmlout_arrayType" . "$xmlout_offset$xml_attr>$xmlout_value</$xmlout_name>"; } + } elseif ($type == 'Array' && !empty($options['keep_arrays_flat'])) { + $xml = $xmlout_value; } else { if (is_null($xmlout_value)) { $xml = "\r\n<$xmlout_name$xmlns$xml_attr/>"; @@ -865,7 +914,7 @@ for ($i = 0; $i < $c; $i++) { $header_xml .= $headers[$i]->serialize($this); } - $header_xml = "<SOAP-ENV:Header>\r\n$header_xml\r\n</SOAP-ENV:Header>\r\n"; + $header_xml = "<".SOAP_BASE::setSOAPENVPrefix().":Header>\r\n$header_xml\r\n</".SOAP_BASE::setSOAPENVPrefix().":Header>\r\n"; } if (!isset($options['input']) || $options['input'] == 'parse') { @@ -880,7 +929,7 @@ } else { $smsg = $method; } - $body = "<SOAP-ENV:Body>\r\n" . $smsg . "\r\n</SOAP-ENV:Body>\r\n"; + $body = "<".SOAP_BASE::setSOAPENVPrefix().":Body>\r\n" . $smsg . "\r\n</".SOAP_BASE::setSOAPENVPrefix().":Body>\r\n"; foreach ($this->_namespaces as $k => $v) { $ns_string .= " xmlns:$v=\"$k\"\r\n"; @@ -894,15 +943,15 @@ * more granular level than we are dealing with here, so this does not * work for all services. */ $xml = "<?xml version=\"1.0\" encoding=\"$encoding\"?>\r\n\r\n". - "<SOAP-ENV:Envelope $ns_string". - ($this->_section5 ? ' SOAP-ENV:encodingStyle="' . SOAP_SCHEMA_ENCODING . '"' : ''). + "<".SOAP_BASE::setSOAPENVPrefix().":Envelope $ns_string". + ($this->_section5 ? ' '.SOAP_BASE::setSOAPENVPrefix().':encodingStyle="' . SOAP_SCHEMA_ENCODING . '"' : ''). ">\r\n". - "$header_xml$body</SOAP-ENV:Envelope>\r\n"; + "$header_xml$body</".SOAP_BASE::setSOAPENVPrefix().":Envelope>\r\n"; return $xml; } - function _makeMimeMessage($xml, $encoding = SOAP_DEFAULT_ENCODING) + function _makeMimeMessage($xml, $encoding = SOAP_DEFAULT_ENCODING, $soap_encoding = 'base64') { if (!@include_once 'Mail/mimePart.php') { return $this->_raiseSoapFault('MIME messages are unsupported, the Mail_Mime package is not installed'); @@ -916,7 +965,7 @@ // Add the xml part. $params['content_type'] = 'text/xml'; $params['charset'] = $encoding; - $params['encoding'] = 'base64'; + $params['encoding'] = $soap_encoding; $msg->addSubPart($xml, $params); // Add the attachements http://cvs.php.net/viewvc.cgi/pear/SOAP/Client.php?r1=1.90&r2=1.91&diff_format=u Index: pear/SOAP/Client.php diff -u pear/SOAP/Client.php:1.90 pear/SOAP/Client.php:1.91 --- pear/SOAP/Client.php:1.90 Wed Jun 27 13:28:02 2007 +++ pear/SOAP/Client.php Tue Sep 25 21:07:00 2007 @@ -531,7 +531,7 @@ $soapAction = false) { $this->fault = null; - $this->_options['input'] = 'parse'; + $this->_options['input'] = 'parse'; $this->_options['result'] = 'parse'; $this->_options['parameters'] = false; @@ -648,7 +648,7 @@ $this->_options['style'] = 'rpc'; $this->docparams = true; $mqname = new QName($method, $namespace); - $methodValue = new SOAP_Value($mqname->fqn(), 'Struct', $params); + $methodValue = new SOAP_Value($mqname->fqn(), 'Struct', $params, array(), $this->_options); $soap_msg = $this->makeEnvelope($methodValue, $this->headersOut, $this->_encoding, @@ -698,7 +698,8 @@ if ((isset($this->_options['attachments']) && $this->_options['attachments'] == 'Mime') || isset($this->_options['Mime'])) { - $soap_msg = $this->_makeMimeMessage($soap_msg, $this->_encoding); + $soap_encoding = isset($this->_options['soap_encoding']) ? $this->_options['soap_encoding'] : 'base64'; + $soap_msg = $this->_makeMimeMessage($soap_msg, $this->_encoding, $soap_encoding); } else { // default is dime $soap_msg = $this->_makeDIMEMessage($soap_msg, $this->_encoding); @@ -801,7 +802,7 @@ } if (is_array($returnArray)) { if (isset($returnArray['faultcode']) || - isset($returnArray['SOAP-ENV:faultcode'])) { + isset($returnArray[SOAP_BASE::setSOAPENVPrefix().':faultcode'])) { $faultcode = $faultstring = $faultdetail = $faultactor = ''; foreach ($returnArray as $k => $v) { if (stristr($k, 'faultcode')) $faultcode = $v; http://cvs.php.net/viewvc.cgi/pear/SOAP/Fault.php?r1=1.22&r2=1.23&diff_format=u Index: pear/SOAP/Fault.php diff -u pear/SOAP/Fault.php:1.22 pear/SOAP/Fault.php:1.23 --- pear/SOAP/Fault.php:1.22 Thu Jan 25 23:14:05 2007 +++ pear/SOAP/Fault.php Tue Sep 25 21:07:00 2007 @@ -75,7 +75,7 @@ { $msg = new SOAP_Base(); $params = array(); - $params[] = new SOAP_Value('faultcode', 'QName', 'SOAP-ENV:' . $this->code); + $params[] = new SOAP_Value('faultcode', 'QName', SOAP_BASE::setSOAPENVPrefix().':' . $this->code); $params[] = new SOAP_Value('faultstring', 'string', $this->message); $params[] = new SOAP_Value('faultactor', 'anyURI', $this->error_message_prefix); if (isset($this->backtrace)) { http://cvs.php.net/viewvc.cgi/pear/SOAP/Transport/SMTP.php?r1=1.28&r2=1.29&diff_format=u Index: pear/SOAP/Transport/SMTP.php diff -u pear/SOAP/Transport/SMTP.php:1.28 pear/SOAP/Transport/SMTP.php:1.29 --- pear/SOAP/Transport/SMTP.php:1.28 Sun Feb 25 12:34:00 2007 +++ pear/SOAP/Transport/SMTP.php Tue Sep 25 21:07:01 2007 @@ -151,7 +151,7 @@ if (!PEAR::isError($result)) { $val = new SOAP_Value('Message-ID', 'string', $headers['Message-ID']); } else { - $sval[] = new SOAP_Value('faultcode', 'QName', 'SOAP-ENV:Client'); + $sval[] = new SOAP_Value('faultcode', 'QName', SOAP_BASE::setSOAPENVPrefix().':Client'); $sval[] = new SOAP_Value('faultstring', 'string', "couldn't send SMTP message to {$this->urlparts['path']}"); $val = new SOAP_Value('Fault', 'Struct', $sval); }