From d8a3aaf9de64ea5dd5fd8465d770b2d019029c9b Mon Sep 17 00:00:00 2001 From: g19i85g Date: Wed, 15 Jul 2015 14:48:05 +0200 Subject: [PATCH 1/2] Fix generate WSDL ```php bindingStyle = WsdlGenerator::STYLE_DOCUMENT; $wsdl = $generator->generateWsdl(TestController::className(), ''); ``` caused: Fatal error: Uncaught exception 'ReflectionException' with message 'Class /yii/helpers/ArrayHelper does not exist' in /app/vendor/conquer/services/WsdlGenerator.php on line 383 --- WsdlGenerator.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/WsdlGenerator.php b/WsdlGenerator.php index f73e7ed..c595741 100644 --- a/WsdlGenerator.php +++ b/WsdlGenerator.php @@ -238,7 +238,7 @@ public function generateWsdl($className, $serviceUrl, $encoding='UTF-8') $this->types=array(); $this->elements=array(); $this->messages=array(); - + $reflection=new \ReflectionClass($className); if($this->serviceName===null) @@ -246,7 +246,7 @@ public function generateWsdl($className, $serviceUrl, $encoding='UTF-8') if($this->namespace===null) $this->namespace='urn:'.str_replace('\\','/',$className).'wsdl'; - + foreach($reflection->getMethods() as $method) { if($method->isPublic()) @@ -381,7 +381,7 @@ protected function processType($type) { // process class / complex type \Yii::autoload($type); $class=new \ReflectionClass($type); - + $type=$class->getShortName(); $comment=$class->getDocComment(); @@ -430,7 +430,7 @@ protected function processType($type) $example=trim($match[1]); $this->types[$type]['properties'][$property->getName()]=array( - $this->processType(str_replace('\\','/',$matches[1])), + $this->processType($matches[1]), trim($matches[3]), $attributes['nillable'], $attributes['minOccurs'], @@ -559,7 +559,7 @@ protected function addTypes($dom) $attribute=$dom->createElement('xsd:attribute'); $attribute->setAttribute('ref','soap-enc:arrayType'); $attribute->setAttribute('arrayType',(isset(self::$typeMap[$arrayType]) ? 'xsd:' : 'tns:') .$arrayType.'[]'); - + $restriction->appendChild($attribute); $complexContent->appendChild($restriction); $complexType->appendChild($complexContent); @@ -579,9 +579,9 @@ protected function addTypes($dom) elseif(is_array($xmlType)) { $pathInfo = pathinfo(str_replace('\\', '/', $phpType)); - + $complexType->setAttribute('name', $pathInfo['basename']); - + //$complexType->setAttribute('name',$phpType); if($xmlType['custom_wsdl']!==false) { From 9ae4da44d3acca6e719a15c75ec50a392ba7427f Mon Sep 17 00:00:00 2001 From: g19i85g <> Date: Wed, 15 Jul 2015 14:53:53 +0200 Subject: [PATCH 2/2] Fix Yii::autoload() fails if the class was included before. ```php Yii::autoload(ArrayHelper::class); Yii::autoload(ArrayHelper::class); ``` caused: Cannot redeclare class yii\helpers\ArrayHelper in /app/vendor/yiisoft/yii2/helpers/ArrayHelper.php --- WebService.php | 10 ++++------ WsdlGenerator.php | 1 - 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/WebService.php b/WebService.php index e848edc..668685f 100644 --- a/WebService.php +++ b/WebService.php @@ -151,7 +151,6 @@ public function generateWsdl() if(is_object($this->provider)) $providerClass=get_class($this->provider); else{ - \Yii::autoload($this->provider); $providerClass=$this->provider; } if($this->wsdlCacheDuration>0 && $this->cacheID!==false && ($cache=\Yii::$app->get($this->cacheID,false))!==null) @@ -241,7 +240,7 @@ public function run() // We need to end application explicitly because of // http://bugs.php.net/bug.php?id=49513 \Yii::$app->state = Application::STATE_AFTER_REQUEST; - \Yii::$app->trigger(Application::EVENT_AFTER_REQUEST); + \Yii::$app->trigger(Application::EVENT_AFTER_REQUEST); $reflect = new \ReflectionClass($e); $server->fault($reflect->getShortName(), $message); exit(1); @@ -283,7 +282,6 @@ protected function getOptions() $options['encoding']=$this->encoding; foreach($this->classMap as $type=>$className) { - \Yii::autoload($className); if(is_int($type)) $type=$className; $options['classmap'][$type]=$className; @@ -326,7 +324,7 @@ public function __call($name,$arguments) { return call_user_func_array(array($this->object,$name),$arguments); } - + /** * Returns the fully qualified name of this class. * @return string the fully qualified name of this class. @@ -377,9 +375,9 @@ public function __call($name,$arguments) { $result = call_user_func_array(array($this->object, $name), $arguments); } - return $result === null ? $result : array($name . 'Result' => $result); + return $result === null ? $result : array($name . 'Result' => $result); } - + /** * Returns the fully qualified name of this class. * @return string the fully qualified name of this class. diff --git a/WsdlGenerator.php b/WsdlGenerator.php index c595741..898350b 100644 --- a/WsdlGenerator.php +++ b/WsdlGenerator.php @@ -379,7 +379,6 @@ protected function processType($type) } else { // process class / complex type - \Yii::autoload($type); $class=new \ReflectionClass($type); $type=$class->getShortName();