Connection with Webservice SOAP WSDL

Asked

Viewed 4,444 times

1

I am trying to get an xml from a Webservice Soap wsdl. With the code below I can get a get on your methods.

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

$result = $client->__getFunctions();

print_r($result);

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

But 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:

I’m doing something wrong?

1 answer

4


I managed to solve the problem by following the tutorial Calling a SOAP Webservice with PHP

Stayed 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);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.