Ver Mensaje Individual
  #2 (permalink)  
Antiguo 28/09/2015, 12:21
Maguak
 
Fecha de Ingreso: agosto-2001
Ubicación: Santiago de Chile
Mensajes: 98
Antigüedad: 22 años, 7 meses
Puntos: 0
Mensaje Respuesta: Webservices Con Utentificación HTTP

Voy a tratar de explicar mejor mi problema.

Tengo que consumir un webservices pero el host me pide autentificación HTTP Basic, entonces no se como autentificarme http basic con php.
Lo he intentado con cURL pero no me resulta.

ejemplo:

try{

$client = new \SoapClient($wsdlCc, array('trace' => 1, "exception" => 0));
// $soap_client->__setLocation($ns);

}catch (SoapFault $fault){

trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR);

}

$param = $params->asXML();

$login = 'user';
$password = 'pass';
// $url = 'http://xxxx/wsOC.asmx';
$url = 'http://xxxx/wsOC.asmx';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "$login:$password");
$result = curl_exec($ch);
curl_close($ch);
echo($result);

try {

$result = $client->__SoapCall('GeneraOC', $param);
print_r($result);
echo '<br/>';

} catch (Exception $e) {
echo __LINE__.' Error: ' . $e->getMessage();
}

print_r($client->__getLastResponse());
die();

Alguien ha tenido este problema y lo ha resuelto?.

Muchas gracias
__________________
maguak