Connection with WebService SOAP WSDL

1

I'm trying to get an xml from a Webservice soap wsdl. With the code below I can give a get in your methods.

$client = new SoapClient('http://www.roveri.inf.br/ws/cnpj.php?wsdl');

$result = $client->__getFunctions();

print_r($result);

Return is: Array ( [0] => string getCNPJ(string $token, string $cnpj) )

However when trying to access the method getCNPJ

$client = new SoapClient('http://www.roveri.inf.br/ws/cnpj.php?wsdl');

$result = $client->getCNPJ($token, $cnpj);

$xml = simplexml_load_string($result);

print_r($xml);

I get an exception:

  

Uncaught SoapFault exception:

Am I doing something wrong?

    
asked by anonymous 28.01.2017 / 19:29

1 answer

2

I was able to solve the problem by following the tutorial Calling a WebService SOAP with PHP

It looks like this:

$client = new SoapClient('http://www.roveri.inf.br/ws/cnpj.php?wsdl');

$function = 'getCNPJ';

$arguments= array(
    'token' => $token,
    'cnpj'  => $cnpj
);

$options = array('location' => 'http://www.roveri.inf.br/ws/cnpj.php');


$result = $client->__soapCall($function, $arguments, $options);

echo 'Response: ';

print_r($result);
    
28.01.2017 / 20:29