Foros del Web » Programando para Internet » PHP »

Consumir un web service .net desde PHP

Estas en el tema de Consumir un web service .net desde PHP en el foro de PHP en Foros del Web. Hola buenas, es la primera vez que me toca trabajar con web services. En este caso tenemos que consumir un web service .net desde php ...
  #1 (permalink)  
Antiguo 05/03/2016, 05:32
 
Fecha de Ingreso: marzo-2016
Mensajes: 1
Antigüedad: 8 años, 1 mes
Puntos: 0
Pregunta Consumir un web service .net desde PHP

Hola buenas,

es la primera vez que me toca trabajar con web services. En este caso tenemos que consumir un web service .net desde php para automatizar una tienda de un cliente. Lo estoy intentando hacer con SoapClient pero no hay manera.

Adjunto un ejemplo de solicitud y respuesta del servicio web mediante SOAP 1.2

Me imagino que tiene que ser algo muy básico pero como no consigo recibir respuesta del webservice ¿Alguién me pueda ayudar?

Muchas gracias.
Saludos.

*** SOLICITUD ****
POST /apps/articulos/Verifica.asmx HTTP/1.1
Host: www.xxxxxxxx.com
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<ValidaUsuarioWSIP xmlns="http://www.xxxxxxxx.com/apps/articulos/Verifica.asmx">
<user>string</user>
<pass>string</pass>
<remote_ip>string</remote_ip>
</ValidaUsuarioWSIP>
</soap12:Body>
</soap12:Envelope>


**** RESPUESTA
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<ValidaUsuarioWSIPResponse xmlns="http://www.xxxxxxxx.com/apps/articulos/Verifica.asmx">
<ValidaUsuarioWSIPResult>
<IPOK>boolean</IPOK>
<USEROK>boolean</USEROK>
<PASSOK>boolean</PASSOK>
<IP>string</IP>
</ValidaUsuarioWSIPResult>
</ValidaUsuarioWSIPResponse>
</soap12:Body>
</soap12:Envelope>
  #2 (permalink)  
Antiguo 07/03/2016, 10:23
 
Fecha de Ingreso: enero-2009
Ubicación: Kandor
Mensajes: 209
Antigüedad: 15 años, 2 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

Etiquetas: soap
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 20:39.