Skip to content

Instantly share code, notes, and snippets.

@allanmedeiros71
Created April 19, 2018 23:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save allanmedeiros71/96e95de5bfe2473f806348ae5ba30f1f to your computer and use it in GitHub Desktop.
Save allanmedeiros71/96e95de5bfe2473f806348ae5ba30f1f to your computer and use it in GitHub Desktop.
<?php
// print "ws_doc_download.php<br>";
// print "Tentativa de consumir o webservice downloadEletronicFile<br>";
// Define usuário e senha
$user = 'sudema';
$pass = "senha";
// IP do servidor
$server = "192.168.4.42";
// URL do WSDL
$wsdl = "http://$server/se/ws/dc_ws.php?wsdl";
$location = "http://$server/softexpert/webserviceproxy/se/ws/dc_ws.php";
// Instancia um cliente SOAP
$client = new SoapClient($wsdl,array(
"trace" => 1, // Habilita o trace
"exceptions" => 0, // Trata as exceções
"login" => $user,
"password" => $pass,
"location" => $location
));
// print "<br>WSDL: $wsdl<br>";
try {
// Tenta consumir o WS
$retorno = $client->downloadEletronicFile(array( "iddocument"=>"2011005779",
"idrevision"=>"",
"iduser"=>"sesuite",
"fgconverttopdf"=>"1",
"idcategory"=>"",
"userAuthentication"=>$user,
"passAuthentication"=>$pass));
// Exibe o PDF no navegador
//header('Content-type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
header('Content-type: application/pdf');
var_dump($retorno->return->item->BINFILE);
// Funcional para word
// header('Content-type: application/msword');
// header("Content-Disposition: attachment; filename=Lote16.doc");
// print $retorno->return->item->BINFILE;
//header('Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
//header("Content-Disposition: attachment; filename=planilha.xlsx");
//print $retorno->return->item->BINFILE;
} catch (SoapFault $exception) {
// Exibe a mensagem de erro
echo "<br>************************<br>";
echo $exception->getMessage();
echo "<br>************************<br>";
}
echo "<br>========= RETORNO =========";
print "<pre>";
//var_dump($retorno);
//var_dump($retorno->return->item[5]->BINFILE);
print "</pre>";
echo "========= REQUEST ==========";
xDebug($client->__getLastRequest());
echo "====== REQUEST HEADERS =====";
xDebug($client->__getLastRequestHeaders());
echo "========= RESPONSE ==========";
xDebug($client->__getLastResponse());
echo "====== RESPONSE HEADERS =====";
xDebug($client->__getLastResponseHeaders());
print "<br>";
function xDebug($objeto) {
print "<pre>".$objeto."</pre>";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment