Galera estou precisando integrar um sistema com webservice da prefeitura de catalao em php, sou meigo no com soap, ai estou utilizando alguns exemplos da net, mais nao estou conseguindo fazer funcionar
Código php utilizado
[php]
$xmlAssinado = $this->makeDados($xml);
$cabecalho = $this->makeCabecalho();
$envelope =
‘<?xml version=“1.0” encoding=“UTF-8”?>
<x:Envelope xmlns:x=“http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.nfse”>
<x:Header/>
<x:Body>
<ser:RecepcionarLoteRpsRequest>
<nfseCabecMsg>’.$cabecalho.‘</nfseCabecMsg>
<nfseDadosMsg>’.$xmlAssinado.‘</nfseDadosMsg>
</ser:RecepcionarLoteRpsRequest>
</x:Body>
</x:Envelope>’;
$url = ‘http://187.111.62.1:8585/prodataws/services/NfseWSService’;
$headers = array(
“Content-type: text/xml; charset=utf-8”,
“SOAPAction: RecepcionarLoteRps”,
"Content-length: ".strlen($envelope),
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 300);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $envelope);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$html = utf8_decode(curl_exec($ch));
header(“Content-type: text/xml”);
echo $html;
file_put_contents(“xmlass.ret”, $html);
curl_close($ch);
[/php]
as funções makeDados e makeCabecalho
[php]
function makeDados($message){
$dom = new \DOMDocument(‘1.0’, ‘UTF-8’);
$dom->preserveWhiteSpace = false;
$dom->formatOutput = false;
$dom->loadXML($message);
$message = str_replace(‘<?xml version=“1.0”?>’, ‘’, $dom->saveXML());
$dados = “<![CDATA[”
. $message
. “]]>”;
return $dados;
}
function makeCabecalho(){
$versao = 2.01;
$cabecalho =
“<![CDATA[”
. “<cabecalho xmlns="{$this->xmlns}" versao="{$versao}"><versaoDados>{$versao}</versaoDados></cabecalho>”
. “]]>”;
return $cabecalho;
}
[/php]
Este é o retorno que esta dando
[xml]
<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope
xmlns:soapenv=“http://schemas.xmlsoap.org/soap/envelope/”>
soapenv:Body</soapenv:Body>
</soapenv:Envelope>
<soapenv:Envelope
xmlns:soapenv=“http://schemas.xmlsoap.org/soap/envelope/”>
soapenv:Body
soapenv:Fault
soapenv:Server
RecepcionarLoteRpsResponse cannot be null!
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
[/xml]