Function ("runcheck") Is Not A Valid Method For This Service


(VladC#) #1

Hi everybody.

CheckupController.php:


ini_set('soap.wsdl_cache_enabled', 0);

ini_set('soap.wsdl_cache_ttl', 0);


class CheckupController extends CController {

    

    public function actions() {

        return array(

            'check' => array(

                'class' => 'CWebServiceAction',

            ),

        );

    }


    /*

     * @return string

     * @soap

     */

    public function runcheck() {

        return 'asdasdasd';

    }

}

client-side code:


$client = new SoapClient('http://localhost/ma/index.php?r=checkup/check');

try {

    $client->runcheck();

} catch (Exception $ex) {

    echo $ex->getMessage();

}

wsdl:


<definitions name="CheckupController" targetNamespace="urn:CheckupControllerwsdl">

    <wsdl:portType name="CheckupControllerPortType"/>

    <wsdl:binding name="CheckupControllerBinding" type="tns:CheckupControllerPortType">

        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>

    </wsdl:binding>

    <wsdl:service name="CheckupControllerService">

        <wsdl:port name="CheckupControllerPort" binding="tns:CheckupControllerBinding">

            <soap:address location="http://localhost/ma/index.php?r=checkup/check&ws=1"/>

        </wsdl:port>

    </wsdl:service>

</definitions>

I know about eAccelerator, about .htaccess with “php_flag eaccelerator.enable 0” and “php_flag eaccelerator.optimizer 0”, but nothing helps me, I keep getting this error. what I do wrong, why wsdl doesn’t contain my function?


(VladC#) #2

I solved issue:

my code:

/*

*/

right code:

/**

*/

1.5 days lost because of only one symbol.


(vitocourt) #3

I´m learning about webservice and I´m the same error.
But, my code is /**

<?php
class WebServiceController extends CController {
   public function actions() {
        return array(
            'wreader' => array(
                'class' => 'CWebServiceAction',
            ),
        );
    }

    /**
     * @param  string tipo_documento
     * @param  string id
     * @param  string type
     * @param  string get_info
     * @param  string regimen
     * @return string the statement
     * @soap
     */
    public function sendCustomer($tipo_documento, $id, $type, $get_info, $regimen) {
    //
        $model = new Customer();
        $model->tipo_documento = $tipo_documento;
        $model->id = $id;
        $model->type = $type;
        $model->get_info = $get_info;
        $model->regimen = $regimen;
        $yesno = $model->save();

        if ($yesno=TRUE) {
            //on success
            return 'Record Saved';
        }
        else {
            //on failure
            return $yesno;
        }
    }   
}

?>

My php plain is

<?php
$client=new SoapClient('http://myUrl.com/prueba/index.php/webService/wreader',array('soap_version'=>SOAP_1_2,'trace'=>true)
	);
$client->sendCustomer('31','1102363258', '1','1','2');
echo $client->__getLastRequest().'<br>';
echo $client->__getLastResponse().'<br>';
?>

The server response is

Fatal error: Uncaught SoapFault exception: [Sender] Function (“sendCustomer”) is not a valid method for this service in C:\wamp\www\serviceBonerp.php:9 Stack trace: #0 C:\wamp\www\serviceBonerp.php(9): SoapClient->__call(‘sendCustomer’, Array) #1 C:\wamp\www\serviceBonerp.php(9): SoapClient->sendCustomer(‘31’, ‘1102363258’, ‘1’, ‘1’, ‘2’) #2 {main} thrown in C:\wamp\www\serviceBonerp.php on line 9

SoapFault: Function (“sendCustomer”) is not a valid method for this service in C:\wamp\www\serviceBonerp.php on line 9

How i can solve this error?