PHP - print_r in xml is bringing class name [closed]

0

I have a class called Cliente.php which makes the connection to the web service and I have another call Requisição.php that generate the XML request and sends it to Cliente.php .

The problem is that the response I get from web service can only show with print_r in class Cliente.php and I can not show in class Requisição.php , even putting Cliente with return .

WHAT SHOWS IS THE NAME IS: Client Object ()

class Cliente {

    public function __construct($requisicao) {
        //Endereço e conexão com  o web service
        $client = new SoapClient("http://192.168.1.104:8082/wsdl/FChamada");
        //Requisição ao web service 
        $obj = $client->Requisicao($requisicao);
        //Retorno(Resposta) do web service
        $xml = simplexml_load_string($obj);
        //Retorna o a resposta do web service
        return $xml;  
    }
}



class Requisicao {

    /***********************************************************************
     ********************* REQUISÃO ****************************************
     **********************************************************************/
    public function query() {

        $req = new Requisicao_XML();
        //Gerando o xml requisição
        $requisicao = $req->toXML();

        //Envia o xml requisição para a classe Cliente e recebe o xml resposta
        $xml = new Cliente($requisicao);
        //Deveria mostrar o xml resposta
        print_r($xml)
    }

}
    
asked by anonymous 16.06.2015 / 13:05

1 answer

0

In the __contruct method there is no return because the return is the object. What you can do in this case is to create a method.

class Cliente {

    public static function Get($requisicao) {
        //Endereço e conexão com  o web service
        $client = new SoapClient("http://192.168.1.104:8082/wsdl/FChamada");
        //Requisição ao web service 
        $obj = $client->Requisicao($requisicao);
        //Retorno(Resposta) do web service
        $xml = simplexml_load_string($obj);
        //Retorna o a resposta do web service
        return $xml;  
    }
}



class Requisicao {

    /***********************************************************************
     ********************* REQUISÃO ****************************************
     **********************************************************************/
    public function query() {

        $req = new Requisicao_XML();
        //Gerando o xml requisição
        $requisicao = $req->toXML();

        //Envia o xml requisição para a classe Cliente e recebe o xml resposta
        $xml = Cliente::Get($requisicao);
        //Mostrar o xml resposta
        print_r($xml)
    }

}
    
16.06.2015 / 13:30