1
I am the days with this problem, I need to consume a wsdl webservice with php.
Follows my code
$cliente = new SoapClient('http://ws.tntbrasil.com.br:81/tntws/CalculoFrete?wsdl'); $funcao = 'calculaFrete'; $parametros = array( 'calculaFrete' => array( 'cepDestino' => '95045080', 'vlMercadoria' => '300.85', 'psReal' => '30.000', 'cdDivisaoCliente' => '1', 'cepOrigem' => '95032620', 'login' => '[email protected]', 'nrIdentifClienteDest' => '00010010099', 'nrIdentifClienteRem' => '10668759000109', 'nrInscricaoEstadualDestinatario' => '', 'nrInscricaoEstadualRemetente' => '0290501580', 'senha' => '', 'tpFrete' => 'C', 'tpPessoaDestinatario' => 'F', 'tpPessoaRemetente' => 'J', 'tpServico' => 'RNC', 'tpSituacaoTributariaDestinatario' => 'CO', 'tpSituacaoTributariaRemetente' => 'ME' ) ); $resultado = $cliente->__soapCall($funcao, $parametros);
You’re making my mistake again
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://ws.tntbrasil.com.br:81/tntws/CalculoFrete?wsdl' : failed to load external entity "http://ws.tntbrasil.com.br:81/tntws/CalculoFrete?wsdl" in /home/eggecom/public_html/tnt/calculaFrete.php:19 Stack trace: #0 /home/eggecom/public_html/tnt/calculaFrete.php(19): SoapClient->SoapClient('http://ws.tntbr...', Array) #1 {main} thrown in /home/eggecom/public_html/tnt/calculaFrete.php on line 19
I have tried in many ways and contacted the webservice provider where he did not give me the desired support but assured me about the variables being right.
from your PHP server, you can access this URL http://ws.tntbrasil.com.br:81/tntws/Calculofrete? wsdl ?
– Denys Xavier
Yeah, no problem at all.
– Tiago Ferreira
If you run this code -->
echo ("<pre>" . htmlentities(file_get_contents('http://ws.tntbrasil.com.br:81/tntws/CalculoFrete?wsdl')) . "</pre>");
the contents of WSDL appears?– Denys Xavier
Yes, I tested now and returned: <? xml version='1.0' encoding='UTF-8'? > <Definitions xmlns:tns="http://service.calculoFrete.mercurio.com" targetNamespace="http://service.calculoFrete.mercurio.com" name="Calculofrete"> <types> <xsd:schema> <xsd:import namespace="http://e.calculoFrete.mercouri.com" schemaLocation="http://ws.tntbrasil.com.br:81/tntws/CalculoFrete? xsd=1"/> </xsd:schema> [...]
– Tiago Ferreira
Just in case, try adding the following line before $client = new Soap....
libxml_disable_entity_loader(false);
. What happens now?– Denys Xavier
Nothing, same mistake :/
– Tiago Ferreira
One last suggestion: remove the libxml_dis... I mentioned before and leave the $client like this:
$cliente = new SoapClient('http://ws.tntbrasil.com.br:81/tntws/CalculoFrete?wsdl', array('cache_wsdl' => WSDL_CACHE_NONE));
. Anyway, you’re looking like something with your server anyway. If the suggestion doesn’t work, start looking at your firewall if you’re allowing traffic on port 81, or something like.– Denys Xavier
Continue: Fatal error: Uncaught Soapfault Exception: [ns0:Server] java.lang.Nullpointerexception Thank you so far!
– Tiago Ferreira
I solved the question: Within $parametros the array should be called in0 and not calculatFrete.
– Tiago Ferreira