Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #1 from evictor/trunk

Added support for XML "nillable" when using SOAP overload extension
  • Loading branch information...
commit c20e0777d80f420439171d11be7eedd7389327d9 2 parents 12044f4 + d826f68
@CloCkWeRX CloCkWeRX authored
Showing with 26 additions and 6 deletions.
  1. +26 −6 SOAP/WSDL.php
View
32 SOAP/WSDL.php
@@ -508,19 +508,25 @@ function _validateString($string)
return preg_match('/^[\w_:#\/]+$/', $string);
}
- function _addArg(&$args, &$argarray, $argname)
+ function _addArg(&$args, &$argarray, $argname, $nillable = false, &$nillableArgs = array())
{
if ($args) {
$args .= ', ';
}
$args .= '$' . $argname;
+ if ($nillable) {
+ $args .= ' = null';
+ $nillableArgs[] = $argname;
+ }
if (!$this->_validateString($argname)) {
return;
}
- if ($argarray) {
- $argarray .= ', ';
+ if (!$nillable) {
+ if ($argarray) {
+ $argarray .= ', ';
+ }
+ $argarray .= "'$argname' => $" . $argname;
}
- $argarray .= "'$argname' => $" . $argname;
}
function _elementArg(&$args, &$argarray, &$_argtype, $_argname)
@@ -694,20 +700,34 @@ function generateProxyCode($port = '', $classname = '')
// XXX need to wrap the parameters in a
// SOAP_Value.
}
+ $usingNillables = false;
+ $nillableArgs = array();
if (isset($el['elements'])) {
foreach ($el['elements'] as $elname => $elattrs) {
$elname = $this->_sanitize($elname);
+ if ((isset($elattrs['nillable']) && $elattrs['nillable'])
+ || (isset($elattrs['minOccurs']) && $elattrs['minOccurs'] == 0)) {
+ // If you encounter one nillable, all subsequent
+ // arguments must default to null
+ $usingNillables = true;
+ }
// Is the element a complex type?
if (isset($this->complexTypes[$elattrs['namespace']][$elname])) {
$comments .= $this->_complexTypeArg($args, $argarray, $_argtype, $_argname);
} else {
- $this->_addArg($args, $argarray, $elname);
+ $this->_addArg($args, $argarray, $elname, $usingNillables, $nillableArgs);
}
}
}
if ($el['complex'] && $argarray) {
$wrapname = '{' . $this->namespaces[$_argtype['namespace']].'}' . $el['name'];
- $comments .= " \${$el['name']} = new SOAP_Value('$wrapname', false, \$v = array($argarray));\n";
+ $comments .= " \$v = array($argarray);\n";
+ if ($usingNillables && !empty($nillableArgs)) {
+ foreach($nillableArgs as $nillableArg) {
+ $comments .= " isset(\$$nillableArg) && \$v['$nillableArg'] = \$$nillableArg;\n";
+ }
+ }
+ $comments .= " \${$el['name']} = new SOAP_Value('$wrapname', false, \$v);\n";
$argarray = "'{$el['name']}' => \${$el['name']}";
}
} else {
Please sign in to comment.
Something went wrong with that request. Please try again.