Skip to content

Commit

Permalink
Fix generate WSDL
Browse files Browse the repository at this point in the history
```php
<?php

use conquer\services\WsdlGenerator;
use yii\web\Controller;

require(__DIR__ . '/vendor/autoload.php');
require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php');

class TestController extends Controller
{
    /**
     * @param TestA $test
     * @soap
     */
    public function test($test)
    {
    }
}

class TestA
{
    /**
     * @var string
     * @soap
     */
    public $property1;
    /**
     * @var \yii\helpers\ArrayHelper
     * @soap
     */
    public $property2;
}

$generator = new WsdlGenerator();
$generator->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
  • Loading branch information
g19i85g committed Jul 16, 2015
1 parent 894cd79 commit d8a3aaf
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions WsdlGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,15 @@ 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)
$this->serviceName=$reflection->getShortName();

if($this->namespace===null)
$this->namespace='urn:'.str_replace('\\','/',$className).'wsdl';

foreach($reflection->getMethods() as $method)
{
if($method->isPublic())
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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'],
Expand Down Expand Up @@ -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);
Expand All @@ -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)
{
Expand Down

0 comments on commit d8a3aaf

Please sign in to comment.