SOAP Web Service

0

I have a very unusual problem with a SOAP application. I have a simple client to do a consumer test.

When I test directly on the view action of the service it returns the result correctly, but when I try to consume the same functionality by a client it returns me null .

I looked at the PHP error log in wamp, and gave the following error:

  

Undefined variable: json in C: \ wamp64 \ www \ service-stsc \ module \ WebService \ src \ WebService \ Api \ WebServiceApi.php on line 591

OBS: I have other functions in this same service and are working normally.

Client:

analise.php

 $client = new SoapClient('http://localhost/service-stsc/webservice/soap?wsdl');

 var_dump($result = $client->__soapCall('ConsultaAnalitica', array( 
       '2017-06-05', 
       '2017-06-05')
 ));

Server:

TSCCOntroller.php

public function analiseAction()
    {
        try
        {
            $webServiceApi = new WebServiceApi(array(TSCController::$TSCModel => $this->getModel(TSCController::$TSCModel)));
            echo $webServiceApi->ConsultaAnalitica($dataInicial,$dataFinal);

            exit;
        }
        catch(\Exception $ex)
        {
            return $ex->getMessage();
        }
    }

WebServiceApi.php

public function ConsultaAnalitica($dataInicial, $dataFinal)
{
    try{
        if (($tscs = $this->TSC->ConsultaAnaliticaSQL($dataInicial, $dataFinal)) != null){                    
            foreach ($tscs as $tsc)
            {
                $array[$tsc->DataHora] = $tsc->Quantidade;
                $json = json_encode($array);
            }

            return $json; <-- LINHA 591
        }
    }
    catch(\Exception $ex)
    {
        $this->Log->Ocorrencia = 2;
        $this->Log->Motivo = 'Problemas na consulta de tsc por data hora através do serviço de integração. Detalhes: ' . $ex->getMessage();

        $this->Log->insertToLog($this->Log->toArray());

        return false;
    }
}

TSCModel.php

public function ConsultaAnaliticaSQL($dataInicial, $dataFinal){
        try{
            $sqlTSC = "SELECT DataHoraOcorrencia as DataHora, COUNT(TSC.ID) as Quantidade FROM TSC WHERE DataHoraOcorrencia BETWEEN '$dataInicial' AND '$dataFinal' GROUP BY DATE(TSC.DataHoraOcorrencia)";
            $TSC = $this->tableGateway->getAdapter()->query($sqlTSC,array());
            return $TSC;

        } catch (\Exception $ex) {
            return $ex->getMessage();
        }
    }
    
asked by anonymous 13.11.2017 / 13:54

0 answers