Ver Mensaje Individual
  #2 (permalink)  
Antiguo 07/03/2016, 10:23
abrahamhs
 
Fecha de Ingreso: enero-2009
Ubicación: Kandor
Mensajes: 209
Antigüedad: 15 años, 3 meses
Puntos: 11
Respuesta: Consumir un web service .net desde PHP

Este es un ejemplo dummy que envia archivos a un webservices, igual y te sirve:

<html>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"/>
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate"/>
<meta http-equiv="Pragma" content="nocache"/>
<script type="text/javascript">
</script>
<body>
<form id="recibeCFD" action="pruebaBoveda.php" method="post" enctype="multipart/form-data" accept-charset="UTF-8">
<input type="file" style="display: inline-block" name="filePDF" id="filePDF" accept="application/pdf" />
<input type="file" style="display: inline-block" name="nomArch" id="nomArch" accept="application/xml" />
<input type="submit" name="submit" id="submit" value="aceptar" />
</form>
<?php
function remove_utf8_bom($text){
$bom = pack('H*','EFBBBF');
$text = preg_replace("/^$bom/", '', $text);
return $text;
}
if (isset($_FILES["nomArch"])){
if (($_FILES["nomArch"]["error"] > 0) && ($_FILES["filePDF"]["error"]>0) &&
(substr($_FILES["filePDF"]["name"],strlen($_FILES["filePDF"]["name"])-3)=="pdf") &&
(substr($_FILES["nomArch"]["name"],strlen($_FILES["nomArch"]["name"])-3)=="xml") ){
echo "Aviso: " . $_FILES["nomArch"]["error"] . "<br>";// Ocurrio un error al abrir el archivo
}else{
$rutaPdf=$_FILES["filePDF"]["tmp_name"];
$strfilePDF = $_FILES["filePDF"]["name"];
$strRutaTemp = $_FILES["nomArch"]["tmp_name"];
$strNomArch = $_FILES["nomArch"]["name"];
$intTamXml = filesize($strRutaTemp);
$intTamPdf = filesize($rutaPdf);
// Tipo MIME
$strTipoXml = mime_content_type($strRutaTemp);
$strTipoPdf = mime_content_type($rutaPdf);
// Contenido
$strContenidoXml = remove_utf8_bom(file_get_contents($strRutaTemp));
$strContenidoPdf = file_get_contents($rutaPdf);
$arreglo=array(
"nomPdf"=> base64_encode($strfilePDF),//base64_encode
"nomarch" => base64_encode($strNomArch),//base64_encode
"intTamXml" => $intTamXml, // int
"intTamPdf" => $intTamPdf , // int
"strTipoXml" => $strTipoXml , //string //tipo mime
"strTipoPdf" => $strTipoPdf , //string //tipo mime
"strContenidoXml" => base64_encode( $strContenidoXml),
"strContenidoPdf" => base64_encode( $strContenidoPdf)
);
ini_set("soap.wsdl_cache_enabled", "0");
try{
$cliente= new SoapClient("http://tu.url.del.webservice.php?WSDL",array('trace' => 1,'login'=>'usuario','password' => 'gfdgdh'));
$strResp = $cliente->__soapCall('metodoOfuncion',array($arreglo));
}catch(SoapFault $fault){
var_dump( array("Error"=>array($fault->faultcode,$fault->faultstring)));
}
}
}
?>
</body>
</html>


Saludos