Created
April 19, 2018 23:18
-
-
Save allanmedeiros71/96e95de5bfe2473f806348ae5ba30f1f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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