<?php 

session_name('excel_a_webservices');



session_start();



if($_POST[web_services]=='Timbrar'){



require_once('nusoap.php');

$xml_armado = $_SESSION[xml_armado];

$xml_armado = str_replace('<?xml version="1.0" encoding="utf-8"?>','',$xml_armado);





if($_SESSION[xml][ambiente]=='QA'){

$client = 

new nusoap_client('https://qa.pegasotecnologia.mx/ServAdmEmisionGatewayQA/ServiceGateway.svc/Soap11Text');

	}elseif($_SESSION[xml][ambiente]=='PROD'){	

		$client = 

new nusoap_client('https://www.pegasotecnologiacfdi.net/ServAdmEmisionGatewayPROD/ServiceGateway.svc/Soap11Text');

		}

				

$err = $client->getError();



if ($err) {

	echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';

}



$result = $client->call('emitirCFD',/*agrega esta línea en tu php utf8_encode*/utf8_decode($xml_armado), 'http://namespace.pegasotecnologia.com/SCFD','http://namespace.pegasotecnologia.com/SCFD/IEmisionBaseExternalService/emitirCFD',



'<Action>http://namespace.pegasotecnologia.com/SCFD/IEmisionBaseExternalService/emitirCFD</Action>','','','literal');



}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<style type="text/css">

.ac{ font-family:Calibri; color:#FF0000;

}

.ap{ font-family:Calibri; color:#006600;}

.ab{ font-family:Calibri; color:#006600;}

#rojo{ color:#FF0000;}

body{ color:#000000; background-color:#EBEBEB;

font-family:Calibri; font-size:14px; font-weight:normal;}

td{ border:1px #00CC00 solid;}

</style>

<title>Editor de txt</title>

</head>



<body><?php

require("links.php");



if ($client->fault) {

	echo '<h2>Fault</h2><pre>';

	print_r($result);

	echo $client->response;

var_dump($person3);



	echo '</pre>';

	

} else {

	$err = $client->getError();

	if ($err) {

		echo '<h2>Error</h2><pre>' . $err . '</pre>';

		var_dump($person3);

		echo $client->response;

	} else {

		echo '<h2>Result</h2><pre>';

		print_r($result);

		echo '</pre>';

		echo $client->response;

var_dump($person3);

		echo "termina";

	}

}

echo '<h2>Request</h2><pre>' . htmlspecialchars($client->request, ENT_NOQUOTES, "UTF-8") . '</pre>';

echo '<h2>Response</h2><pre>' . htmlspecialchars($client->response, ENT_NOQUOTES, "UTF-8") . '</pre>';

?>



</body>