Permalink
Browse files

[UPDATE] bug fix and improvements

Fix generated setSoapHeader method in service classes

Improve WsdlToPhpModel class in order to ensure that none of the
WsdlClass methods is overriden by a WSDL operation
  • Loading branch information...
mikaelcom committed Apr 10, 2013
1 parent 1f3451c commit 1c8978389719d76e1d0855d3fddd6ee7863c6e2c
Showing with 29 additions and 19 deletions.
  1. +10 −0 WsdlClassFileTpl.php
  2. +17 −17 WsdlToPhpModel.php
  3. +2 −2 WsdlToPhpService.php
View
@@ -232,6 +232,16 @@ public static function getDefaultWsdlOptions()
self::WSDL_URL=>null,
self::WSDL_USER_AGENT=>null);
}
+ /**
+ * Allows to set the SoapClient location to call
+ * @uses PackageNameWsdlClass::getSoapClient()
+ * @uses SoapClient::__setLocation()
+ * @param string $_location
+ */
+ public function setLocation($_location)
+ {
+ return self::getSoapClient()?self::getSoapClient()->__setLocation($_location):false;
+ }
/**
* Returns the last request content as a DOMDocument or as a formated XML String
* @see SoapClient::__getLastRequest()
View
@@ -46,7 +46,7 @@ class WsdlToPhpModel
* Plus {PackageName}WsdlClass specific/common methods
* @var string
*/
- private static $phpReserverKeywords = 'add|getResult|count|current|item|offsetGet|offsetSet|key|last|first|next|offsetExists|offsetUnset|rewind|setResult|toSend|valueIsValid|valid|_set|_get|__halt_compiler|abstract|and|array|as|break|callable|case|catch|class|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|eval|exit|extends|final|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|namespace|new|or|print|private|protected|public|require|require_once|return|static|switch|throw|trait|try|unset|use|var|while|xor';
+ private static $phpReserverKeywords = '__construct|getSoapClient|setSoapClient|initSoapClient|setLocation|getDefaultWsdlOptions|getLastRequest|getLastResponse|getFormatedXml|add|getResult|length|count|current|item|offsetGet|offsetSet|key|last|first|next|offsetExists|offsetUnset|rewind|setResult|toSend|valueIsValid|valid|getLastError|setLastError|saveLastError|getLastErrorForMethod|getInternArrayToIterate|setInternArrayToIterate|getInternArrayToIterateOffset|initInternArrayToIterate|setInternArrayToIterateOffset|getInternArrayToIterateIsArray|setInternArrayToIterateIsArray|getAttributeName|__toString|_set|_get|__halt_compiler|abstract|and|array|as|break|callable|case|catch|class|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|eval|exit|extends|final|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|namespace|new|or|print|private|protected|public|require|require_once|return|static|switch|throw|trait|try|unset|use|var|while|xor';
/**
* Replaced keywords time in order to generate unique new keyword
* @var array
@@ -540,26 +540,26 @@ protected static function uniqueName($_name,$_context)
*/
public static function getValueWithinItsType($_value,$_knownType = null)
{
- if(is_int($_value) || in_array($_knownType,array(
- 'time',
- 'positiveInteger',
- 'unsignedLong',
- 'unsignedInt',
- 'short',
- 'long',
- 'int',
- 'integer')))
+ if(is_int($_value) || (!is_null($_value) && in_array($_knownType,array(
+ 'time',
+ 'positiveInteger',
+ 'unsignedLong',
+ 'unsignedInt',
+ 'short',
+ 'long',
+ 'int',
+ 'integer'))))
return intval($_value);
- elseif(is_float($_value) || in_array($_knownType,array(
- 'float',
- 'double',
- 'decimal')))
+ elseif(is_float($_value) || (!is_null($_value) && in_array($_knownType,array(
+ 'float',
+ 'double',
+ 'decimal'))))
return floatval($_value);
elseif(is_numeric($_value))
return intval($_value) == $_value?intval($_value):floatval($_value);
- elseif(is_bool($_value) || in_array($_knownType,array(
- 'bool',
- 'boolean')))
+ elseif(is_bool($_value) || (!is_null($_value) && in_array($_knownType,array(
+ 'bool',
+ 'boolean'))))
return ($_value === 'true' || $_value === true || $_value === 1 || $_value === '1');
else
return $_value;
View
@@ -173,11 +173,11 @@ public function getClassBody(&$_body)
array_push($_body,'}');
array_push($_body,'if(!empty($_actor))');
array_push($_body,'{');
- array_push($_body,'array_push($defaultHeaders,new SoapHeader($_nameSpace,\'' . $soapHeaderName . '\',$_' . lcfirst($cleanedName) . ',$_mustUnderstand,$_actor));');
+ array_push($_body,'array_push($defaultHeaders,new SoapHeader($_nameSpace,\'' . $soapHeaderName . '\',$_' . lcfirst($headerParamKnown?$soapHeaderType:$cleanedName) . ',$_mustUnderstand,$_actor));');
array_push($_body,'}');
array_push($_body,'else');
array_push($_body,'{');
- array_push($_body,'array_push($defaultHeaders,new SoapHeader($_nameSpace,\'' . $soapHeaderName . '\',$_' . lcfirst($cleanedName) . ',$_mustUnderstand));');
+ array_push($_body,'array_push($defaultHeaders,new SoapHeader($_nameSpace,\'' . $soapHeaderName . '\',$_' . lcfirst($headerParamKnown?$soapHeaderType:$cleanedName) . ',$_mustUnderstand));');
array_push($_body,'}');
array_push($_body,'return self::getSoapClient()->__setSoapheaders($defaultHeaders);');
array_push($_body,'}');

0 comments on commit 1c89783

Please sign in to comment.