Yii 1.1: wsdl2php

Generate soap client proxy classes from wsdl url

This extension wraps easywsdl2php as gii module.

It's an easy to use WSDL to PHP code generator. Just enter the address of the WSDL and the application will generate the library that you will use to write your code.

I did some minor changes to the original EasyWsdl2PHP.php code (formatting, 'extends' params) but did't change the code generation.

No warrenty that easywsdl always will be able to generate valid code, but for my purpose it works (tested with Silverlight/Delphi/Yii soap servers).


  • Yii 1.6 or above
  • PHP SOAP extension installed


  • Extract the content of the zipfile to /protected/gii
  • Enable gii in config/main.php
  • Call index.php/gii and select 'Wsdl2Php Generator'


  • Set 'http://www.webservicex.net/geoipservice.asmx?WSDL' as WSDL Service Url
  • Set 'GeoIpService' as Service classname

gii will generate the class file 'GeoIpService.php' in protected/components (=default). This file contains all necessary classes generated from wsdl.

Create a controller action:

public function actionMyIp()
        $geoIpService = new GeoIpService;
        $response = $geoIpService->GetGeoIPContext(new GetGeoIPContext);
        $geoIp = $response->GetGeoIPContextResult;
        echo sprintf('Your IP: %s (%s, %s)',$geoIp->IP,$geoIp->CountryName,$geoIp->CountryCode);

If you want you can

  • Change the destination directory (Yii path alias syntax)
  • Add base classnames that the (param and main) classes should extend.




  • fixed another Lower/Uppercase issue: see comment 8019 and 7706 below. Thanks to robdlyon.


  • fixed the issue that the extension was not displayed in gii (non windows users)
  • no code changed, only renamed the files/classes from Wsdl2PhpGenerator.php to Wsdl2phpGenerator.php ...

Total 13 comments

#13050 report it
Maurice_ at 2013/04/30 09:48am
WSDL Service Url is not a valid URL

Hello and thanks for the extension. I have still some problems with calling webservices. I get the error "WSDL Service Url is not a valid URL" when I placed my wsdl file in an accessible directory and called "http://localhost/yii_app_path/my.wsdl". The wsdl file is accessible when I call the url in my browser. Another thing that I tried was to echo out the whole file content in a php file. That also did not work. Any ideas?

#12806 report it
andrwsv at 2013/04/12 07:16pm
i need help with send params and recive params

Hi, I install and generated the file with class of conection but i dont know how send params and recive params of web services:

this is code generate: class getTransactionInformation { public $request; //getTransactionInformationType; }

class getTransactionInformationType { public $EntityCode; //string; public $TicketId; //string; }

class getTransactionInformationResponse { public $getTransactionInformationResult; //getTransactionInformationResponseType; }

class getTransactionInformationResponseType { public $EntityCode; //string; public $TicketId; //string; public $TrazabilityCode; //string; public $TranState; //string; public $ReturnCode; //string; public $TransValue; //decimal; public $TransVatValue; //decimal; public $PayCurrency; //string; public $CurrencyRate; //decimal; public $BankProcessDate; //date; public $BankName; //string; public $PaymentSystem; //string; public $ReferenceArray; //string; public $RetriesTicketId; //retriesTicketIdType; }

class retriesTicketIdType { public $TicketId; //string; public $TranState; //string; }

class createTransactionPayment { public $request; //createTransactionType; }

class createTransactionType { public $EntityCode; //string; public $SrvCode; //string; public $TransValue; //decimal; public $TransVatValue; //decimal; public $SrvCurrency; //string; public $URLResponse; //string; public $URLRedirect; //string; public $Sign; //string; public $SignFields; //string; public $ReferenceArray; //string; }

class createTransactionPaymentResponse { public $createTransactionPaymentResult; //createTransactionResponseType; }

class createTransactionResponseType { public $ReturnCode; //string; public $TicketId; //string; public $eCollectUrl; //string; }

/** * The soap client proxy class */ class PruebasWsdl { public $soapClient;

private static $classmap = array(

function __construct($url='http://zeus.mipuntodepago.com/d_express/webservice/eCollectWebservicesv2.asmx?wsdl')
$this->soapClient = new SoapClient($url,array("classmap"=>self::$classmap,"trace" => true,"exceptions" => true));

function getTransactionInformation($getTransactionInformation)
    $getTransactionInformationResponse = $this->soapClient->getTransactionInformation($getTransactionInformation);
    return $getTransactionInformationResponse;

function createTransactionPayment($createTransactionPayment)
    $createTransactionPaymentResponse = $this->soapClient->createTransactionPayment($createTransactionPayment);
    return $createTransactionPaymentResponse;


as Instantius several classes in one file and not see yii mistake that can not find the class

#11054 report it
Joblo at 2012/12/12 10:13am
Code generation

Sorry, I can't help with this issue, because it is a problem of the easywsdl2php implementation.

I have only implemented the wrapper, so that it can be used as gii module and I didn't study the implementation of easywsdl2php.

#11052 report it
Daniele Cicognini at 2012/12/12 10:04am
Problems in code generated

Hi Joblo, I have some problems with the generated code, when a webservice operation have input message and output message like these:

<!-- INPUT -->
<message name="CWS_ConfermaOrdineRequest">
<part name="CWv_RecordID" type="xsd:int"/>
<part name="CWv_Accantona" type="xsd:int"/>
<!-- OUTPUT -->
<message name="CWS_ConfermaOrdineResponse">
<part name="CWv_ErrorNum" type="xsd:int"/>
<part name="CWv_ErrorText" type="xsd:string"/>

Thre generated code is:

function $CWv_ErrorNum, string $CWv_ErrorText CWS_ConfermaOrdine($int)

Tried also with the patch proposed by Patrice and the result is:

function $CWv_ErrorNum, string $CWv_ErrorText CWS_ConfermaOrdine($CWv_RecordID,$CWv_Accantona)
#9027 report it
Patrice at 2012/07/14 02:12am
multipes parameters

Nice extension. I just changed the vendor source(EasyWsdl2PHP.php) in order to manage functions that have more than one parameter.

$params = explode(' ', $par);
            // Original code : only 1 parameter is processed
            $p1 = '$' . $params[0];
            // Begin of modification : any parameters are processed
            $p1 = '';
            for ($i = 1; $i <= count($params)/2; $i++) {
                $p1 .= $params[2*$i-1];
            // End of modification
            $code .= $nl . $nl .'function ' . $func . '(' . $p1 .')'
            . "{$nl}{";
            // Begin of modification : list of parameters inserted as a comment
                $code .=  $nl ."\t// Parameters : {$par}";
            // End of modification
            if ($temp[0] == 'void')
#8020 report it
jmariani at 2012/05/04 12:30am
Not Generating Code

Now it's working.

Thank you very much!

#8018 report it
Ivanda Nothabeer at 2012/05/03 07:59pm
Not Generating Code

See comment 7706 for the solution.

It looks like the fix in v0.5.1 wasn't finished correctly

#8017 report it
jmariani at 2012/05/03 07:22pm
Not working


I managed to get it installed within Gii, but when I click the "Preview" button, nothing shows up under the list of generated code.

I'm using Yii 1.1.10., MAMP 2.0.2, OSX Lion.


#7706 report it
Ivanda Nothabeer at 2012/04/10 11:14pm
Extension not running in Win 7 + IIS

I downloaded V0.5.1 but could not get it to run. I eventually traced it to a problem with my version of wsdl2php\Wsdl2phpGenerator.php

"Wsdl2PhpCode" should be replaced with "Wsdl2phpCode" ....

class Wsdl2phpGenerator extends CCodeGenerator
    public $codeModel='application.gii.wsdl2php.Wsdl2phpCode';

Otherwise, a really usefull extension for me. Thanks

#7203 report it
Joblo at 2012/03/03 02:54pm
extension not visible in gii

fixed in v0.5.1 gii was searching for a file 'Wsdl2phpGenerator.php' but the filename was 'Wsdl2PhpGenerator.php', so I didn't realize this, because I'm working on windows...

#6958 report it
meadows at 2012/02/15 10:47pm
I followed these instructions to the letter but...

I don't see wsdl2php in my gii. I don't have any other gii extensions installed so I tried with and without the application path set. Do I need something else installed as well?

#6237 report it
Joblo at 2011/12/21 03:20am
install path

Extract the files under /protected/gii.

gii is looking for extensions by default in this path.

So the files of the extension are located under:

YIIDIR/protected/gii/wsdl2php/Wsdl2PhpCode.php ...

If you have installed another gii extension (giix,...), where the generatorPaths is specified you have to add this defaultpath too:

              ... //other paths here
             'application.gii' //<-- add the default path

You call gii with index.php?r=gii (or index.php/gii if urlManager is configured)

#6234 report it
wtfbrb at 2011/12/20 11:00pm
Please update instructions on use...

I believe it is supposed to be index.php?r=gii and I don't know where to extract those files as putting it in /protected/gii or in yiidir/gii made anything like Wsdl2Php Generator appear in gii...

Leave a comment

Please to leave your comment.

Create extension