Integração webservice Soap WSDL

Enviada por Rodrigo 
Rodrigo
Integração webservice Soap WSDL
18 de August de 2015 às 02:21PM
Pessoal, Boa tarde

Achei um exemplo muito prático sobre a utilização de webservice com PHP usando soapClient utilizei dos códigos do exemplo e realmente funcionou 100 %, o problema é que o exemplo abaixo funciona perfeitamente, porém utilizando um webservice que preciso realizar algumas consultas não é possível ocorre um erro:

[soap:Server] HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted.

Abaixo os códigos de exemplo Funcionando

<?php
$client = new SoapClient('http://www.webservicex.net/ConvertTemperature.asmx?WSDL');

$function = 'ConvertTemp';

$arguments= array('ConvertTemp' => array(
'Temperature' => 31,
'FromUnit' => 'degreeCelsius',
'ToUnit' => 'degreeFahrenheit'
));
$options = array('location' => 'http://www.webservicex.net/ConvertTemperature.asmx');

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

echo 'Response: ';
print_r($result);
?>



COM ERRO


<?php
$client = new SoapClient('https://homologacao.lmcws.fazenda.pr.gov.br/lmcws/AutorizacaoWS?wsdl');


$function = 'lmcAutorizacao';

$arguments= array('xmlDados' => '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:sef="http://www.fazenda.pr.gov.br/wsdl/sefaws"><soap:Header/><soap:Body><sef:lmcAutorizacao><xmlDados> <autorizacao xmlns="http://www.fazenda.pr.gov.br/sefaws"><livroCombustivel xmlns="http://www.fazenda.pr.gov.br/sefaws"><infLivroCombustivel versao="1.00" Id="LMC2015080706923637000136123459"><tpAmb>2</tpAmb><cNumerico>12345</cNumerico><cDV>9</cDV><emit><IE>9031600712</IE><CNPJ>06923637000136</CNPJ><xNome>KAIROS AUTO POSTO</xNome></emit><movimento dEmissao="2013-05-31"><infMovimento nrProduto="4"><volEstoqueAbertura>3241.544</volEstoqueAbertura><volumeRecebido><CNPJ>34274233026241</CNPJ><nNF>888146</nNF><dNF>2013-05-31</dNF><volVolume>10000.000</volVolume><xTanque>0005</xTanque></volumeRecebido><volumeVendido><xTanque>0005</xTanque><nrBico>2</nrBico><volFechamento>563971.040</volFechamento><volAbertura>563304.660</volAbertura><volAfericoes>0.000</volAfericoes></volumeVendido><volumeVendido><xTanque>0005</xTanque><nrBico>4</nrBico><volFechamento>254829.500</volFechamento><volAbertura>253890.170</volAbertura><volAfericoes>0.000</volAfericoes></volumeVendido><volumeVendido><xTanque>0005</xTanque><nrBico>6</nrBico><volFechamento>684371.300</volFechamento><volAbertura>683826.780</volAbertura><volAfericoes>0.000</volAfericoes></volumeVendido><volumeVendido><xTanque>0005</xTanque><nrBico>8</nrBico><volFechamento>539227.080</volFechamento><volAbertura>538636.880</volAbertura><volAfericoes>0.000</volAfericoes></volumeVendido><volEstoqueFechamento>4018.026</volEstoqueFechamento><valVendasDiaBomba>8261.77</valVendasDiaBomba><valAcumuladoMes>8261.77</valAcumuladoMes><observacoes></observacoes></infMovimento></movimento></infLivroCombustivel><Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" /><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" /><Reference URI="#LMC2015080706923637000136123459"><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" /><Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" /></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /><DigestValue>iBHEFvXXW4+vIPWiJneKYuUEvjw=</DigestValue></Reference></SignedInfo><SignatureValue>F1ADH+fVF2A1HndNmnZQ67vhFMlZ00ni1t5xp+rGJt0fMZHRQ5raUhFh5CTjbBeBcVX62QRUyI2iRvk+sYSu8NaKPziGw6WyrohPTKTz4U3GMmB6aAjhpk/RnIINg/TvhL0bLikGGCCtsqUQzP7pQHCpH4P8GSJ9R7TAwBWYE8VuOJHJYrrEH3L1/UXOZXExVxJbAMXDTXVuP3/L6lcoVe6d5IzWCfu3EdaV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GLMF8GCCsGAQUFBzAChlNodHRwOi8vaWNwLWJyYXNpbC5jZXJ0aXNpZ24uY29tLmJyL3JlcG9zaXRvcmlvL2NlcnRpZmljYWRvcy9BQ19DZXJ0aXNpZ25fUkZCX0c0LnA3YzAoBggrBgEFBQcwAYYcaHR0cDovL29jc3AuY2VydGlzaWduLmNvbS5icjANBgkqhkiG9w0BAQsFAAOCAgEAwGaRGSVZ28QsfF2wXYwOgE4BD09qNbl1HZFHiVb5JmGQGVgo5fGwriTSrYln+oXAoWOId68fjjjBylJYZi7gfrxGUmxYTKTYghDibXYPZmqadcgq2odFdPqgW1DHjlj8nq6D0Gx1ak7DEtfW1Pok1UfDmtfEuHQMcWj/rT6dqT2LzrcoZPlB0co0N5dVrvrb43V5WpP1iSTiNGM4lUimED6BcsnH3xpbIhDXKDXPvGWPQrwJvEEkQctBWWLv3cx2V8zRESzgF6rjJiuHA8ZRSXE+9fIJfPcj+NTKwnGdHVb/X/HXXuPHZLOqeidVnW2TWb6RL9gQNRTR9aadi86qwt5d+C2HnFAeWPk4vN/W4sE2JVNocxgR+HpbQx47yhxbXSYAMnQaPnBxLD0Os63JrjvL/n9P7DhStrwMm/1aRX89MAC9O1RSIkQRKQtJUOzwXngJ3OYf729+3sqrpIi+TXhIvQx5sDZBGpiOUnma/qpCLEYlNbRKQC87YhSWGiucB9o/TpzPKKjZVu7bPozuh0F3QNsqVfFhzNn5fql7lEY//2o8THVihyHuAizh3pEed+8JmlMG+0jF2QUzdRJiKwHxDvndW/gpDj2MbmBfDtxDnkFm4LD6qn63ZXXWo3Au3H/iklFsBA7STPKcBXZihae/J1SZBzKSZ/NO+fdGGig=</X509Certificate></X509Data></KeyInfo></Signature></livroCombustivel></autorizacao></xmlDados></sef:lmcAutorizacao></soap:Body></soap:Envelope>');

$options = array('location' => 'https://homologacao.lmcws.fazenda.pr.gov.br/lmcws/AutorizacaoWS');

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

//$result = $client->lmcAutorizacao($arguments);

//$result = $client->__call('lmcAutorizacao', $arguments);

echo 'Response: ';
print_r($result);
?>
rafael sapata
Re: Integração webservice Soap WSDL
30 de September de 2015 às 09:56AM
Bom dia Rodrigo,

Conseguiu solucionar o problema ? Estamos com a mesma dificuldade.
rafael sapata
Re: Integração webservice Soap WSDL
01 de October de 2015 às 09:32AM
Problema resolvido erro era na versão do SOAP.
Você precisa estar logado no PHPBrasil.com para poder enviar mensagens para os nossos fóruns.

Faça o login aqui.