Programación en PHP/Avanzado/XML en PHP 5

De Wikilibros, la colección de libros de texto de contenido libre.
Ir a la navegación Ir a la búsqueda
@$sCodUsu=$_GET['wcodusu'];
@$sClave=$_GET['wclave'];
@$sCurso=$_GET['wcurso'];
@$iCodAsi=$_GET['wcodasi'];
@$sCodConv=$_GET['wcodconv'];
@$sOrden=$_GET['worden'];
if ($sOrden=="") $sOrden="D";

//LLAMADA AL WEB SERVICE
$client = new SoapClient(null, array('location' => 'https://uxxi.cpd.ua.es:7779/UA-SI/WSS',
                                     'uri'      => 'http://UASI/WSS.wsdl',
                                     'encoding' => 'ISO-8859-1',
                                     'trace'	=> 1) ); // el parámetro trace es para mostrar el XML interno
$pLengua     = new SoapVar($sLengua , XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema");
$pCodUsuario = new SoapVar($sCodUsu , XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema");
$pClave      = new SoapVar($sClave , XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema");
$pCurso      = new SoapVar($sCurso , XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema");
$pCodAsi     = new SoapVar($iCodAsi , XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema");
$pConv       = new SoapVar($sCodConv , XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema");
$pOrden      = new SoapVar($sOrden , XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema");
try 
{	
	$resultado = $client->wsfechaexamenesasi2(new SoapParam($pLengua, 'plengua'),
                                             new SoapParam($pCodUsuario, 'pcodusuario'),				
                                             new SoapParam($pClave, 'pclave'),				
                                             new SoapParam($pCurso, 'pcurso'),
                                             new SoapParam($pCodAsi, 'pcodasi'),
                                             new SoapParam($pConv, 'pconvocatoria'),		                        
                                             new SoapParam($pOrden, 'porden') );
	
}
catch (SoapFault $exception)	//CONTROLAMOS LA EXCEPCIONES
{
	//Si el mensaje de error es nuestro, lo limpiamos para verlo mejor
	$delimitador = '@@';
	$e = $exception->faultstring;
    $p = strpos($e, $delimitador);
    if ($p !== false)
    {
    	$q = strpos ($e, $delimitador,$p+2);
    	$sError = substr($e, $p+2, $q-$p-2);
		echo "ERROR: ",$sError,"<BR>";
    }
    else
    {
    	echo $e;
    }
	die();
}


// MOSTRAMOS LOS RESULTADOS
if ($sLengua == "C")
{
    $sTxtDia = "Día";
    $sTxtAsi = "Asignatura";
    $sTxtGrp = "Grupo";
    $sTxtConv = "Convocatoria";
    $sTxtObs = "Observaciones";
    $sTxtAulas = "Aulas";
}
else
{
    $sTxtDia = "Dia";
    $sTxtAsi = "Assignatura";
    $sTxtGrp = "Grup";
    $sTxtConv = "Convocatòria";
    $sTxtObs = "Observacions";
    $sTxtAulas = "Aules";
}

echo "<HTML><HEAD>\n";
echo "</HEAD><BODY>\n";

echo "<TABLE>\n";
echo "<tbody>\n";
echo "<TR>\n";
if ($sOrden=='D')
{
	echo " <TH>",$sTxtDia,"</TH>\n";
	echo " <TH>",$sTxtAsi,"</TH>\n";
	echo " <TH>",$sTxtGrp,"</TH>\n";
	echo " <TH>",$sTxtConv,"</TH>\n";
	echo " <TH>",$sTxtObs,"</TH>\n";
	echo " <TH>",$sTxtAulas,"</TH>\n";
}
elseif ($sOrden=='A')
{
	echo " <TH>",$sTxtAsi,"</TH>\n";
	echo " <TH>",$sTxtGrp,"</TH>\n";
	echo " <TH>",$sTxtConv,"</TH>\n";
	echo " <TH>",$sTxtDia,"</TH>\n";
	echo " <TH>",$sTxtObs,"</TH>\n";
	echo " <TH>",$sTxtAulas,"</TH>\n";
}
else
{
	echo " <TH>",$sTxtConv,"</TH>\n";
	echo " <TH>",$sTxtAsi,"</TH>\n";
	echo " <TH>",$sTxtGrp,"</TH>\n";
	echo " <TH>",$sTxtDia,"</TH>\n";
	echo " <TH>",$sTxtObs,"</TH>\n";
	echo " <TH>",$sTxtAulas,"</TH>\n";
}
echo "</TR>\n";

for ($i=0; $i<count($resultado->array);$i++)
{
	$valor = $resultado->array[$i];
	
	echo "<TR>\n";
	
	if ($sOrden=='D')
	{
		echo " <TD>",$valor->fecha,"</TD>\n";
		echo " <TD>",$valor->codasi,': ',$valor->nomasi,"</TD>\n";
		echo " <TD>",$valor->codgrp,"</TD>\n";
		echo " <TD>",$valor->codconv,': ',$valor->conv,"</TD>\n";
		echo " <TD>",$valor->observaciones,"</TD>\n";
		echo " <TD>",$valor->aulas,"</TD>\n";
	}
	elseif ($sOrden=='A')
	{
		echo " <TD>",$valor->codasi,': ',$valor->nomasi,"</TD>\n";
		echo " <TD>",$valor->codgrp,"</TD>\n";
		echo " <TD>",$valor->codconv,': ',$valor->conv,"</TD>\n";
		echo " <TD>",$valor->fecha,"</TD>\n";
		echo " <TD>",$valor->observaciones,"</TD>\n";
		echo " <TD>",$valor->aulas,"</TD>\n";
	}
	else
	{
		echo " <TD>",$valor->codconv,': ',$valor->conv,"</TD>\n";
		echo " <TD>",$valor->codasi,': ',$valor->nomasi,"</TD>\n";
		echo " <TD>",$valor->codgrp,"</TD>\n";
		echo " <TD>",$valor->fecha,"</TD>\n";
		echo " <TD>",$valor->observaciones,"</TD>\n";
		echo " <TD>",$valor->aulas,"</TD>\n";
	}

	echo "</TR>\n";
}
echo "</tbody>\n";
echo "</TABLE>\n";

echo "</BODY>\n";
echo "</HTML>\n";
?>