Web services in CakePHP - complex types February 17, 2006
Posted by rossoft in CakePHP.trackback
I’ve updated the 3 files referenced in the previous post. Now it is easy to pass arrays and structs.
Complete example of usage of server side:
vendor(’nusoap/web_services_controller’);
class ArticulosServicesController extends WebServicesController
{
var $name=’ArticulosServices’;
var $uses=array(’Articulo’,'Familia’);
var $api=array(
‘add’=>array ( ‘doc’=>’agregar articulo’,
‘input’=>array(’codigo’=>’xsd:string’,
‘nombre’=>’xsd:string’,
‘precio’=>’xsd:float’)),
‘browse’=>array(’doc’=>’precio articulo’,
’output’=>array(’return’=>’Array_Articulos’)),
‘precio’=>array(’doc’=>’precio articulo’,
’input’=>array(’codigo’=>’xsd:string’),
’output’=>array(’return’=>’xsd:integer’))
);
var $complexTypes=array(
‘Array_Articulos’=>array(’array’=>’Articulo’),
‘Articulo’=>array(’struct’=>array(
‘codigo’=>’xsd:string’,
‘nombre’=>’xsd:string’,
‘precio’=>’xsd:float’)));
function add($codigo,$nombre,$precio)
{
$data['Articulo']['codigo']=$codigo;
$data['Articulo']['nombre']=$nombre;
$data['Articulo']['precio_pvp']=$precio;
$this->Articulo->save($data);
}
function precio($codigo)
{
$data=$this->Articulo->findAll(”Articulo.codigo =’$codigo’”);
if ($data)
{
return $data[0]['Articulo']['precio_pvp'];
}
else
{
return new soap_fault(’Client’,”,’Este artículo no existe.’,”);
}
}
function browse()
{
$ret=array();
$data=$this->Articulo->findAll();
foreach ($data as $art)
{
$ret[]=array(’codigo’=>$art['Articulo']['codigo'],
‘nombre’=>$art['Articulo']['nombre'],
‘precio’=>$art['Articulo']['precio_pvp']);
}
return $ret;
}
}
?>
What about WSDL generating, and using webservice server from ex. java where we have mirror of export class methods not calling single adresses servers ????
I don’t understand you…but if you asked if this aproach generates a WSDL file, it does.
When you put the url of the webservice in your webbrowser, and then click on link ‘WSDL’ you obtain a copy of the WSDL file generated.
Hi. I keep getting this error when trying to consume a IIS Web Service:
Array
(
[faultcode] => soap:Server
[faultstring] => Server was unable to process request. –> Object reference not set to an instance of an object.
[detail] =>
)
There’s so many people in forums asking for the same thing, but no solution. Can you help me?
Hi there, it’s me again. I found the solution here:
http://users.skynet.be/pascalbotte/rcx-ws-doc/nusoapadvanced.htm
I just wanted you to know.
BTW, you have a great site!
Felicitaciones.
american history, general information, general resources
Nice site with good info!
american life, general information, general resources
Just found your site. Will definitely come back soon!
american history, general information, general resources
More posts like the one above would be greatly appreciated.
health acne rosacea skincare
great site love the info presented.
tattoos henna temporary tattoos
great site love the info presented.