Hi - I have been looking how to return a binary file on a web service and using the Yii built in functionality i don’t see an option to activate a MTOM data type base64binary, the framework only maps simple types like:
str/string: maps to xsd:string;
int/integer: maps to xsd:int;
float/double: maps to xsd:float;
bool/boolean: maps to xsd:boolean;
date: maps to xsd:date;
time: maps to xsd:time;
datetime: maps to xsd:dateTime;
array: maps to xsd:string;
object: maps to xsd:struct;
mixed: maps to xsd:anyType.
i have been trying to return a string data type with base64 encoded string but it doesn’t works, do someone knows how to do this?
My code:
/**
* @param int id document id
* @return string base64 encoded document
* @soap
*/
public function getDocument($id) {
$model=Document::model()->findByPk((int) $id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
$file = $model->file_pdf;
if($file != null) {
$binfile = $this->getFile($file);
}
return $binfile;
}
Thank you for your response mrk, but what i need is to use MTOM funcionality, it is supposed more efficient to transmit files embedded on webservices than base64 strings because the size of the file is increased 33%, in my code im getting this
This datatype it’s supposed to be xsi:type=“base64Binary” and it appears as xsi:type=“xsd:string”
I had a quick glance at Yii WSDL generation codes. What I found is that all this config can unfortunately be used with CWsdlGenerator because even if you pass some additional config to it, it’s clearing all private properies (that can be customized) before wsdl generation.
However I don’t think you have to change anything in this config.
You have your method that returns this encoded base64, it’s probably in some kind of facade etc, and to integrate it with soap it have some annotations added.
Can you show signature of this method, and probably some random other one (to compare)? Because I guess, all you’ll have to do to solve this problem will be to set proper type in annotation.