How to use Web Services in Yii 1?

0

I followed the steps of the tutorial below but I'm having an error when I call via client soap.

link

DRIVER:

<?php ini_set('soap.wsdl_cache_enabled', 0); ini_set('soap.wsdl_cache_ttl', 10); ini_set('default_socket_timeout', 15); ini_set('always_populate_raw_post_data', -1);

class WsController extends CController
{           
    public function actions() 
    {
        return array(

            'pti' => array(

                'class'     => 'CWebServiceAction', // ext.GWebService.GSoapServerAction | CWebServiceAction
            ),
        );
    }
    /**
     * @param string seu nome
     * @return string saudação
     * @soap
     */
    public function hello($str) 
    {
        return 'Hello ' . $str . '!';
    }
}

SOAP:

header('Content-Type: text/plain;'); ini_set ( 'soap.wsdl_cache_enable' , 0 ); ini_set ( 'soap.wsdl_cache_ttl' , 0 );

$wsdl       = '_MINHA_URL_/webservice/ws/pti?wsdl';
$options    = array(
    'uri'                   => 'http://schemas.xmlsoap.org/soap/envelope/',
    'style'                 => SOAP_RPC,
    'use'                   => SOAP_ENCODED,
    'soap_version'          => SOAP_1_1,
    'cache_wsdl'            => WSDL_CACHE_NONE,
    'connection_timeout'    => 15,
    'trace'                 => true,
    'encoding'              => 'UTF-8',
    'exceptions'            => true,
);  

$client=new SoapClient($wsdl, $options);

try 
{       
    $result=$client->__soapCall('hello', array('Dan')); //$result=$client->hello('Danilo');
} 

catch (SoapFault $e) 
{
    echo '--------------------------------------------------------' . PHP_EOL;
    echo '[SoapFault Exception]: '  . $e->getMessage()              . PHP_EOL;
    echo '--------------------------------------------------------' . PHP_EOL;
    echo PHP_EOL;

    echo '[RESPONSE]: '             . $client->__getLastResponse()  . PHP_EOL;
    echo PHP_EOL;

    echo '[REQUEST]: '              . $client->__getLastRequest()   . PHP_EOL;
    echo PHP_EOL;
}

RETURN:

--------------------------------------------------------
[SoapFault Exception]: looks like we got no XML document
--------------------------------------------------------

[RESPONSE]: <?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:WsControllerwsdl" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:helloResponse><return xsi:type="xsd:string">Hello Dan!</return></ns1:helloResponse></SOAP-ENV:Body></SOAP-ENV:Envelop

[REQUEST]: <?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:WsControllerwsdl" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:hello><str xsi:type="xsd:string">Dan</str></ns1:hello></SOAP-ENV:Body></SOAP-ENV:Envelope>
    
asked by anonymous 09.07.2018 / 16:56

0 answers