CWsdlGenerator enhancement


I’d like to add another type to CWsdlGenerator, xsd:base64Binary, but I don’t seem to find how to properly extend CWsdlGenerator.

This class is used by CWebService but it is hardcoded, at line 140:

$generator=new CWsdlGenerator

Wouldn’t make sense to create a new public property $generator which defaults to CWsdlGenerator?

public $generator = 'CWsdlGenerator';

// and later in the method

$generator = new $this->generator;

Thus we can easily create a new wsdl generator and tell the service to use it.


A little bit more work, but an alternative:

You can define the an extended CWebServiceAction, overwrite the CWebServiceAction::createWebService function to call an extended CWebService.

So define and pass through the $generator variable and overwrite the CWebService::generateWsdl function


Already did this. But the whole implementation is rigid. For example I had to add another type (base64) but the types are hardcoded inside a private method, had to copy-paste the entire class just for this…

Maybe the base64 type could be handled as a non-primitive user-class-defined type.

But don’t get me wrong, I don’t say that your feature request is not a good point.

Did you solved it?

I need to download an image stored as a blob in the database using a webservice…and i remmember that with NuSoap the blob field was mapped as "xsd:base64Binary"


Well you can make it better by creating WebService function to call an extended CWebService.

Hi - How did you solve this to base64binary? i’m having the same problem, currently i’m using string containing a base64_encode() result as string.

It worked for me:

echo '<div align="center"><img class="detailimage" src="data:'.$model_resurce->mimeType.';base64,' . base64_encode($model_resurce->resource ) . '" /></div>';

Hope it helps.

Hi jorgito_ml, thank you, did you put this html code inside the WebService? how?

First you have to store the image contents in the database (I use a LongBlob field):

protected function beforeValidate()



		if($this->auxFile =CUploadedFile::getInstance($this,'uploadedFile'))







		return parent::beforeValidate();


Then use the above code to show the image.