Expenses es un sistema para la gestión de viáticos con grandes ventajas y aplicaciones que permitirá el control y administración de gastos de esta índole permitiendo disminuir gastos innecesarios. El presente documento presenta las dos formas con las que expenses cuenta para poder integrarse con el flujo de tu empresa.
Es importante saber que existen dos tipos de cuenta para usar Expenses:
1) Cuenta de prueba
La cuenta de prueba permitirá realizar pruebas sin necesidad de exponer datos reales y sin generar costos. De ésta forma se pueden realizar pruebas de integración de forma segura y gratuita. Se puede solicitar una cuenta de prueba enviando un correo a soportecloud@masnegocio.com.
Web Service tipo rest:
URL: http://qa.core.masnegocio.com/mn-e-xpenses-integracion-v10/servicios
Web Service tipo SOAP:
URL: http://qa.core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios?wsdl
2) Cuenta producción
La cuenta de producción se usará una vez se haya llegado a una integración exitosa. Es importante lograr una aplicación estable y flexible que pueda adaptarse fácilmente en caso de requerir cambios o actualizaciones futuras del servicio de integración.
Web Service tipo rest:
URL: https://core.masnegocio.com/mn-e-xpenses-integracion-v10/servicios
Web Service tipo SOAP:
URL: https://core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios?wsdl
Descarga aquí el archivo para conocer más a fondo los servicios, las entradas requeridas y sus respuestas.
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio de Actualiza Comprobnte
private function ActualizaComprobante($token,$id_comprobante){
$contentXML = "";
$contentXML += "";
$contentXML += " ";
$contentXML += "";
$contentXML += "";
$contentXML += "" + token + " ";
$contentXML += "" + id_comprobante + " ";
$contentXML += " ";
$contentXML += " ";
$contentXML += " ";
$postData = $contentXML;
$length = count($postData);
$headers = array("Content-type: text/xml;charset=\"utf-8\"",
"SOAPAction: http://radt.expenses.services/services/ActualizaComprobante",
"Content-length: ".strlen($postData));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios');
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, $length);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,10);
curl_setopt($ch, CURLOPT_TIMEOUT,10);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result=curl_exec($ch);
if($result === false) {
echo "es falso";
$err = 'Curl error: ' . curl_error($ch);
curl_close($ch);
print $err;
} else {
curl_close($ch);
}
return $result;
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST de Actualiza Comprobnte
define("URL", "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion");
$HEADERS = array('Content-Type: application/json', 'token: eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiB9.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=');
function updateComprobacion($id){
$ch = curl_init();
global $HEADERS;
curl_setopt($ch, CURLOPT_URL, URL."/comprobacion/".$id);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $HEADERS);
$output = curl_exec($ch);
print_r($output);
curl_close($ch);
}
La siguiente función describe la invocación de e-Xpense para solicitar el servicio Comprobante Pendiente
private function ComprobantePendiente($token,$id_comprobante){
$contentXML = "";
$contentXML += "";
$contentXML += " ";
$contentXML += "";
$contentXML += "";
$contentXML += "" + token + " ";
$contentXML += "" + id_comprobante + " ";
$contentXML += "";
$contentXML += " ";
$contentXML += " ";
$postData = $contentXML;
$length = count($postData);
$headers = array("Content-type: text/xml;charset=\"utf-8\"",
"SOAPAction: http://radt.expenses.services/services/ComprobantePendiente",
"Content-length: ".strlen($postData));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios');
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, $length);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,10);
curl_setopt($ch, CURLOPT_TIMEOUT,10);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result=curl_exec($ch);
if($result === false) {
echo "es falso";
$err = 'Curl error: ' . curl_error($ch);
curl_close($ch);
print $err;
} else {
curl_close($ch);
}
return $result;
}
La siguiente función describe la invocación de e-Xpense para solicitar el servicio REST Comprobante Pendiente
define("URL", "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion");
$HEADERS = array('Content-Type: application/json', 'token: eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiB9.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=');
function getComprobacion($id){
$ch = curl_init();
global $HEADERS;
curl_setopt($ch, CURLOPT_URL, URL."/comprobacion/".$id);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $HEADERS);
$output = curl_exec($ch);
print_r($output);
curl_close($ch);
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio de Comnprobantes pendientes
private function ComprobantesPendientes($token){
$contentXML = "";
$contentXML += "";
$contentXML += " ";
$contentXML += "";
$contentXML += "";
$contentXML += "" + token + " ";
$contentXML += "";
$contentXML += " ";
$contentXML += " ";
$postData = $contentXML;
$length = count($postData);
$headers = array("Content-type: text/xml;charset=\"utf-8\"",
"SOAPAction: http://radt.expenses.services/services/ComprobantesPendientes",
"Content-length: ".strlen($postData));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios');
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, $length);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,10);
curl_setopt($ch, CURLOPT_TIMEOUT,10);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result=curl_exec($ch);
if($result === false) {
echo "es falso";
$err = 'Curl error: ' . curl_error($ch);
curl_close($ch);
print $err;
} else {
curl_close($ch);
}
return $result;
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST de Comnprobantes pendientes
define("URL", "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion");
$HEADERS = array('Content-Type: application/json', 'token: eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiB9.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=');
function getComprobaciones(){
$ch = curl_init();
global $HEADERS;
curl_setopt($ch, CURLOPT_URL, URL."/comprobaciones");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $HEADERS);
$output = curl_exec($ch);
$curl_errno = curl_errno($ch);
print_r($curl_errno);
print_r($output);
curl_close($ch);
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST Ususario
define("URL", "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion");
$HEADERS = array('Content-Type: application/json', 'token: eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiB9.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=');
$usuario = array(
"i_clave" => null,
"empresa" => "K001",
"jefe" => "802345",
"centro_costo" => "K0010055",
"grupo" => "Empleados",
"usuario_acl" => "YTREJOPEMN3",
"no_empleado" => "12345678911",
"appat" => "Trejo",
"apmat" => "Perez",
"nombre" => "Tonatiu",
"passwd" => "root",
"mail" => "pancho.perez.perez@gmail.com",
"cuenta_pagar" => "0000000",
"cuenta_cobrar" => "0000000",
"es_empleado" => "S",
"es_director" => "N",
"puesto" => utf8_encode("Señor de la pape"),
"foto" => null,
"estatus" => null,
"admin" => array(
"usuario" => "PRAMIREZMN",
"passwd" => "PRAMIREZMN"
)
);
createUsuario(json_encode($usuario));
function createUsuario($body){
$ch = curl_init();
global $HEADERS;
curl_setopt($ch, CURLOPT_URL, URL."/usuario");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_HTTPHEADER, $HEADERS);
$output = curl_exec($ch);
print_r($output);
curl_close($ch);
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST Ususario
define("URL", "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion");
$HEADERS = array('Content-Type: application/json', 'token: eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiB9.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=');
function getUsuario($id){
$ch = curl_init();
global $HEADERS;
curl_setopt($ch, CURLOPT_URL, URL."/usuario/".$id);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $HEADERS);
$output = curl_exec($ch);
print_r($output);
curl_close($ch);
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST Ususarios
define("URL", "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion");
$HEADERS = array('Content-Type: application/json', 'token: eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiB9.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=');
function getUsuarios(){
$ch = curl_init();
global $HEADERS;
curl_setopt($ch, CURLOPT_URL, URL."/usuarios");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $HEADERS);
$output = curl_exec($ch);
$curl_errno = curl_errno($ch);
print_r($curl_errno);
print_r($output);
curl_close($ch);
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST Actualizar Usuario
define("URL", "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion");
$HEADERS = array('Content-Type: application/json', 'token: eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiB9.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=');
function updateUsuario($body){
$ch = curl_init();
global $HEADERS;
curl_setopt($ch, CURLOPT_URL, URL."/usuario");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $HEADERS);
$output = curl_exec($ch);
print_r($output);
curl_close($ch);
}
$usuario = array
(
"i_clave" => 132,
"empresa" => "K010",
"jefe" => "802345",
"centro_costo" => "K0010055",
"grupo" => "Empleados",
"usuario_acl" => "YTREJOPEMN3",
"no_empleado" => "12345678911",
"appat" => "Trejo",
"apmat" => "Perez",
"nombre" => "Yahuitl",
"passwd" => "root",
"mail" => "pancho.perez.perez@gmail.com",
"cuenta_pagar" => "0000000",
"cuenta_cobrar" => "0000000",
"es_empleado" => "S",
"es_director" => "N",
"puesto" => utf8_encode("Señor de la copiadora"),
"foto" => null,
"estatus" => null,
"admin" => array(
"usuario" => "PRAMIREZMN",
"passwd" => "PRAMIREZMN"
)
);
updateUsuario(json_encode($usuario));
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST Crear Concepto
define("URL", "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion");
$HEADERS = array('Content-Type: application/json', 'token: eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiB9.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=');
$concepto = array(
"i_clave" => null,
"nombre" => "Cosas de prueba 4",
"codigo" => "CPSH4",
"cuenta" => "CC-01267848",
"cfdi" => "S",
"pdf" => "N",
"archivo" => "N",
"arch_extranjero" => "N",
"propina" => "S",
"estatus" => null
);
createConcepto(json_encode($concepto));
function createConcepto($body){
$ch = curl_init();
global $HEADERS;
curl_setopt($ch, CURLOPT_URL, URL."/concepto");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_HTTPHEADER, $HEADERS);
$output = curl_exec($ch);
print_r($output);
curl_close($ch);
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST Concepto
define("URL", "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion");
$HEADERS = array('Content-Type: application/json', 'token: eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiB9.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=');
function getConcepto($id){
$ch = curl_init();
global $HEADERS;
curl_setopt($ch, CURLOPT_URL, URL."/concepto/".$id);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $HEADERS);
$output = curl_exec($ch);
print_r($output);
curl_close($ch);
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST Conceptos
define("URL", "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion");
$HEADERS = array('Content-Type: application/json', 'token: eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiB9.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=');
function getConceptos(){
$ch = curl_init();
global $HEADERS;
curl_setopt($ch, CURLOPT_URL, URL."/conceptos");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $HEADERS);
$output = curl_exec($ch);
$curl_errno = curl_errno($ch);
print_r($curl_errno);
print_r($output);
curl_close($ch);
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST Actualizar Concepto
define("URL", "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion");
$HEADERS = array('Content-Type: application/json', 'token: eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiB9.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=');
function updateConcepto($body){
$ch = curl_init();
global $HEADERS;
curl_setopt($ch, CURLOPT_URL, URL."/concepto");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $HEADERS);
$output = curl_exec($ch);
print_r($output);
curl_close($ch);
}
$concepto =
array(
"i_clave" => 6,
"nombre" => "Cosas de prueba prueba 3",
"codigo" => "CPSH4",
"cuenta" => "CC-01267847",
"cfdi" => null,
"pdf" => "S",
"archivo" => null,
"arch_extranjero" => null,
"propina" => null,
"estatus" => null
);
updateConcepto(json_encode($concepto));
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST Crear Centro de costos
define("URL", "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion");
$HEADERS = array('Content-Type: application/json', 'token: eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiB9.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=');
$ceco = array(
"i_clave" => 1,
"empresa" => "K010",
"divisa" => "MXN",
"gerente" => "12345678910",
"nombre" => "Fake CeCo",
"codigo" => "K00100100",
"estatus" => null
);
createCeCo(json_encode($ceco));
function createCeCo($body){
$ch = curl_init();
global $HEADERS;
curl_setopt($ch, CURLOPT_URL, URL."/centro-costos");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_HTTPHEADER, $HEADERS);
$output = curl_exec($ch);
print_r($output);
curl_close($ch);
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST Centro de costos
define("URL", "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion");
$HEADERS = array('Content-Type: application/json', 'token: eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiB9.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=');
function getCeCo($id){
$ch = curl_init();
global $HEADERS;
curl_setopt($ch, CURLOPT_URL, URL."/centro-costos/".$id);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $HEADERS);
$output = curl_exec($ch);
print_r($output);
curl_close($ch);
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST Centros de costos
define("URL", "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion");
$HEADERS = array('Content-Type: application/json', 'token: eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiB9.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=');
function getCeCos(){
$ch = curl_init();
global $HEADERS;
curl_setopt($ch, CURLOPT_URL, URL."/centros-costos");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $HEADERS);
$output = curl_exec($ch);
$curl_errno = curl_errno($ch);
print_r($curl_errno);
print_r($output);
curl_close($ch);
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST Actualizar Centro de costos
define("URL", "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion");
$HEADERS = array('Content-Type: application/json', 'token: eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiB9.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=');
function updateCeCo($body){
$ch = curl_init();
global $HEADERS;
curl_setopt($ch, CURLOPT_URL, URL."/centro-costos");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $HEADERS);
$output = curl_exec($ch);
print_r($output);
curl_close($ch);
}
$ceco = array(
"i_clave" => 1,
"empresa" => "K010",
"divisa" => "MXN",
"gerente" => null,
"nombre" => "Dirección",
"codigo" => "K0010048",
"estatus" => "O"
);
updateCeCo(json_encode($ceco));
La siguiente función describe la invocación al servicio de e-Xpenses para solicitar el servicio Actuliza comprobante
public static String ActualizaComprobante(String token, String id_comprobante)
{
String contentXML = "";
String response = "";
try
{
contentXML += "";
contentXML += " ";
contentXML += "";
contentXML += "<>";
contentXML += "" + token + " ";
contentXML += "" + id_comprobante + " ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
Uri uri = new Uri("https://core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios");
WebRequest webRequest = WebRequest.Create(uri);
webRequest.ContentType = "text/xml;charset=UTF-8";
webRequest.ContentLength = contentXML.Length;
webRequest.Headers.Add( "SOAPAction", "http://radt.expenses.services/services/ActualizaComprobante");
webRequest.Method = "POST";
webRequest.GetRequestStream().Write(Encoding.UTF8.GetBytes(contentXML), 0, contentXML.Length);
using (WebResponse webResponse = webRequest.GetResponse())
{
using (StreamReader streamReader = new StreamReader(webResponse.GetResponseStream()))
{
response = streamReader.ReadToEnd();
}
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.ReadLine();
}
return response;
}
La siguiente función describe la invocación al servicio de e-Xpenses para solicitar el servicio REST Actuliza comprobante
private static void updateComprobacion(String id)
{
var url = string.Format(RestExample.url, "/comprobacion/", id);
var webrequest = (HttpWebRequest)System.Net.WebRequest.Create(url);
webrequest.Method = "PUT";
webrequest.Headers["Content-Type"] = "application/json";
webrequest.Headers["token"] = "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiB9.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=";
Task task = Task.Factory.FromAsync(
webrequest.BeginGetResponse,
asyncResult => webrequest.EndGetResponse(asyncResult),
(object)null);
var responce = task.ContinueWith(t => ReadStreamFromResponse(t.Result));
}
La siguiente función describe la invocación al servicio de e-Xpenses para solicitar el servicio de Comprobante Pendiente
public static String ComprobantePendiente(String token, String id_comprobante)
{
String contentXML = "";
String response = "";
try
{
contentXML += "";
contentXML += " ";
contentXML += "";
contentXML += "";
contentXML += "" + token + " ";
contentXML += "" + id_comprobante + " ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
Uri uri = new Uri("https://core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios");
WebRequest webRequest = WebRequest.Create(uri);
webRequest.ContentType = "text/xml;charset=UTF-8";
webRequest.ContentLength = contentXML.Length;
webRequest.Headers.Add( "SOAPAction", "http://radt.expenses.services/services/ComprobantePendiente");
webRequest.Method = "POST";
webRequest.GetRequestStream().Write(Encoding.UTF8.GetBytes(contentXML), 0, contentXML.Length);
using (WebResponse webResponse = webRequest.GetResponse())
{
using (StreamReader streamReader = new StreamReader(webResponse.GetResponseStream()))
{
response = streamReader.ReadToEnd();
}
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.ReadLine();
}
return response;
}
La siguiente función describe la invocación al servicio de e-Xpenses para solicitar el servicio REST de Comprobante Pendiente
private static void getComprobacion(String id)
{
var url = string.Format(RestExample.url, "/comprobacion/", id);
var webrequest = (HttpWebRequest)System.Net.WebRequest.Create(url);
webrequest.Method = "GET";
webrequest.Headers["Content-Type"] = "application/json";
webrequest.Headers["token"] = "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiB9.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=";
Task task = Task.Factory.FromAsync(
webrequest.BeginGetResponse,
asyncResult => webrequest.EndGetResponse(asyncResult),
(object)null);
var responce = task.ContinueWith(t => ReadStreamFromResponse(t.Result));
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio de Comprobantes pendientes
public static String ComprobantesPendientes(String token)
{
String contentXML = "";
String response = "";
try
{
contentXML += "";
contentXML += " ";
contentXML += "";
contentXML += "";
contentXML += "" + token + " ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
Uri uri = new Uri("https://core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios");
WebRequest webRequest = WebRequest.Create(uri);
webRequest.ContentType = "text/xml;charset=UTF-8";
webRequest.ContentLength = contentXML.Length;
webRequest.Headers.Add( "SOAPAction", "http://radt.expenses.services/services/ComprobantesPendientes");
webRequest.Method = "POST";
webRequest.GetRequestStream().Write(Encoding.UTF8.GetBytes(contentXML), 0, contentXML.Length);
using (WebResponse webResponse = webRequest.GetResponse())
{
using (StreamReader streamReader = new StreamReader(webResponse.GetResponseStream()))
{
response = streamReader.ReadToEnd();
}
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.ReadLine();
}
return response;
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST Comprobantes pendientes
private static void getComprobaciones()
{
var url = string.Format(RestExample.url, "/comprobaciones", "");
var webrequest = (HttpWebRequest)System.Net.WebRequest.Create(url);
webrequest.Method = "GET";
webrequest.Headers["Content-Type"] = "application/json";
webrequest.Headers["token"] = "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiB9.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=";
Task task = Task.Factory.FromAsync(
webrequest.BeginGetResponse,
asyncResult => webrequest.EndGetResponse(asyncResult),
(object)null);
var responce = task.ContinueWith(t => ReadStreamFromResponse(t.Result));
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio SOAP Crear Usuario
namespace ConsoleApp1
{
class doc
{
public class usuario
{
public String i_clave;
public String empresa;
public String jefe;
public String centro_costo;
public String grupo;
public String usuario_acl;
public String no_empleado;
public String appat;
public String apmat;
public String nombre;
public String mail;
public String cuenta_pagar;
public String cuenta_cobrar;
public String es_empleado;
public String es_director;
public String puesto;
public String foto;
public String estatus;
public String passwd;
}
public class admin
{
public String usuario;
public String passwd;
}
public static String crearUsuario(String token, usuario u, admin a)
{
String contentXML = "";
String response = "";
try
{
contentXML += "";
contentXML += " ";
contentXML += "";
contentXML += "";
contentXML += "" + token + " ";
contentXML += "";
contentXML += "" + u.i_clave + " ";
contentXML += "" + u.empresa + " ";
contentXML += "" + u.jefe + " ";
contentXML += "" + u.centro_costo + " ";
contentXML += "" + u.grupo + " ";
contentXML += "" + u.usuario_acl + " ";
contentXML += "" + u.no_empleado + " ";
contentXML += "" + u.appat + " ";
contentXML += "" + u.apmat + " ";
contentXML += "" + u.nombre + " ";
contentXML += "" + u.mail + " ";
contentXML += "" + u.cuenta_pagar + " ";
contentXML += "" + u.cuenta_cobrar + " ";
contentXML += "" + u.es_empleado + " ";
contentXML += "" + u.es_director + " ";
contentXML += "" + u.puesto + " ";
contentXML += "" + u.foto + " ";
contentXML += "" + u.estatus + " ";
contentXML += "" + u.passwd + " ";
contentXML += "";
contentXML += "" + a.usuario + " ";
contentXML += "" + a.passwd + " ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
Console.WriteLine(contentXML);
Uri uri = new Uri("https://core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios");
WebRequest webRequest = WebRequest.Create(uri);
webRequest.ContentType = "text/xml;charset=UTF-8";
webRequest.ContentLength = contentXML.Length;
webRequest.Headers.Add( "SOAPAction", "http://radt.expenses.services/services/CrearUsuario");
webRequest.Method = "POST";
webRequest.GetRequestStream().Write(Encoding.UTF8.GetBytes(contentXML), 0, contentXML.Length);
using (WebResponse webResponse = webRequest.GetResponse())
{
using (StreamReader streamReader = new StreamReader(webResponse.GetResponseStream()))
{
response = streamReader.ReadToEnd();
}
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.ReadLine();
}
return response;
}
static void Main(string[] args)
{
usuario u = new usuario();
admin a = new admin();
String token = "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiwgImNvbm5lY3Rpb25faWQiOiJjbm5FeHBlbnNlc1NlbWlsbGFWMTAifQ==.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=";
u.i_clave = "";
u.empresa = "K001";
u.jefe = "802345";
u.centro_costo = "K0010055";
u.grupo = "Empleados";
u.usuario_acl = "XYZ2040";
u.no_empleado = "12345678940";
u.appat = "Ruiz";
u.apmat = "Sanchez";
u.nombre = "Juan Carlos";
u.mail = "juan.carlos@gmail.com";
u.cuenta_pagar = "0000000";
u.cuenta_cobrar = "0000000";
u.es_empleado = "S";
u.es_director = "N";
u.puesto = "Jefe de departamento";
u.foto = "";
u.estatus = "";
u.passwd = "12345679";
a.usuario = "PRAMIREZMN";
a.passwd = "PRAMIREZMN";
Console.WriteLine(crearUsuario(token, u, a));
Console.ReadLine();
}
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST Crear Usuario
namespace RestExample
{
class RestExample
{
private static String url = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion{0}{1}";
private static void ReadStreamFromResponse(WebResponse response)
{
using (Stream responseStream = response.GetResponseStream())
using (StreamReader sr = new StreamReader(responseStream))
{
string strContent = sr.ReadToEnd();
Console.WriteLine(strContent);
}
}
private static void creaUsuario(String body)
{
var url = string.Format(RestExample.url, "/usuario", "");
var webrequest = (HttpWebRequest)System.Net.WebRequest.Create(url);
webrequest.Method = "POST";
webrequest.Headers["Content-Type"] = "application/json";
webrequest.Headers["token"] = "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiB9.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=";
StreamWriter stream = new StreamWriter(webrequest.GetRequestStreamAsync().Result);
stream.Write(body);
stream.Flush();
Task task = Task.Factory.FromAsync(
webrequest.BeginGetResponse,
asyncResult => webrequest.EndGetResponse(asyncResult),
(object)null);
var responce = task.ContinueWith(t => ReadStreamFromResponse(t.Result));
}
static void Main(string[] args)
{
String body = "{" +
"\"i_clave\":null," +
"\"empresa\":\"K001\"," +
"\"jefe\":\"802345\"," +
"\"centro_costo\":\"K0010055\"," +
"\"grupo\":\"Empleados\"," +
"\"usuario_acl\":\"YTREJOPEMN70\"," +
"\"no_empleado\":\"12345678914\"," +
"\"appat\":\"Rios\"," +
"\"apmat\":\"Olmos\"," +
"\"nombre\":\"Albero\"," +
"\"passwd\":\"root\"," +
"\"mail\":\"a_olmos2@hotmail.com\"," +
"\"cuenta_pagar\":\"0000000\"," +
"\"cuenta_cobrar\":\"0000000\"," +
"\"es_empleado\":\"S\"," +
"\"es_director\":\"N\"," +
"\"puesto\":\"Ejecutivo de ventas :v\"," +
"\"foto\":null," +
"\"estatus\":null," +
"\"admin\":{" +
"\"usuario\":\"PRAMIREZMN\"," +
"\"passwd\":\"PRAMIREZMN\"" +
"}" +
"}";
RestExample.creaUsuario(body);
Console.ReadLine();
}
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio SOAP Usuario
public static String usuario(String token, String id_usuario)
{
String contentXML = "";
String response = "";
try
{
contentXML += "";
contentXML += " ";
contentXML += "";
contentXML += "";
contentXML += "" + token + " ";
contentXML += "" + id_usuario + " ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
Uri uri = new Uri("https://core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios");
WebRequest webRequest = WebRequest.Create(uri);
webRequest.ContentType = "text/xml;charset=UTF-8";
webRequest.ContentLength = contentXML.Length;
webRequest.Headers.Add( "SOAPAction", "http://radt.expenses.services/services/Usuario");
webRequest.Method = "POST";
webRequest.GetRequestStream().Write(Encoding.UTF8.GetBytes(contentXML), 0, contentXML.Length);
using (WebResponse webResponse = webRequest.GetResponse())
{
using (StreamReader streamReader = new StreamReader(webResponse.GetResponseStream()))
{
response = streamReader.ReadToEnd();
}
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.ReadLine();
}
return response;
}
h2>C# - REST - Usuario
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST Usuario
namespace RestExample
{
class RestExample
{
private static String url = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion{0}{1}";
private static void ReadStreamFromResponse(WebResponse response)
{
using (Stream responseStream = response.GetResponseStream())
using (StreamReader sr = new StreamReader(responseStream))
{
string strContent = sr.ReadToEnd();
Console.WriteLine(strContent);
}
}
private static void getUsuario(String id)
{
var url = string.Format(RestExample.url, "/usuario/", id);
var webrequest = (HttpWebRequest)System.Net.WebRequest.Create(url);
webrequest.Method = "GET";
webrequest.Headers["Content-Type"] = "application/json";
webrequest.Headers["token"] = "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiB9.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=";
Task task = Task.Factory.FromAsync(
webrequest.BeginGetResponse,
asyncResult => webrequest.EndGetResponse(asyncResult),
(object)null);
var responce = task.ContinueWith(t => ReadStreamFromResponse(t.Result));
}
static void Main(string[] args)
{
RestExample.getUsuario("113");
Console.ReadLine();
}
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio SOAP Usuarios
public static String usuarios(String token)
{
String contentXML = "";
String response = "";
try
{
contentXML += "";
contentXML += " ";
contentXML += "";
contentXML += "";
contentXML += "" + token + " ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
Uri uri = new Uri("https://core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios");
WebRequest webRequest = WebRequest.Create(uri);
webRequest.ContentType = "text/xml;charset=UTF-8";
webRequest.ContentLength = contentXML.Length;
webRequest.Headers.Add( "SOAPAction", "http://radt.expenses.services/services/Usuarios");
webRequest.Method = "POST";
webRequest.GetRequestStream().Write(Encoding.UTF8.GetBytes(contentXML), 0, contentXML.Length);
using (WebResponse webResponse = webRequest.GetResponse())
{
using (StreamReader streamReader = new StreamReader(webResponse.GetResponseStream()))
{
response = streamReader.ReadToEnd();
}
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.ReadLine();
}
return response;
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST Usuarios
namespace RestExample
{
class RestExample
{
private static String url = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion{0}{1}";
private static void ReadStreamFromResponse(WebResponse response)
{
using (Stream responseStream = response.GetResponseStream())
using (StreamReader sr = new StreamReader(responseStream))
{
string strContent = sr.ReadToEnd();
Console.WriteLine(strContent);
}
}
private static void getUsuarios()
{
var url = string.Format(RestExample.url, "/usuarios", "");
var webrequest = (HttpWebRequest)System.Net.WebRequest.Create(url);
webrequest.Method = "GET";
webrequest.Headers["Content-Type"] = "application/json";
webrequest.Headers["token"] = "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiB9.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=";
Task task = Task.Factory.FromAsync(
webrequest.BeginGetResponse,
asyncResult => webrequest.EndGetResponse(asyncResult),
(object)null);
var responce = task.ContinueWith(t => ReadStreamFromResponse(t.Result));
}
static void Main(string[] args)
{
RestExample.getUsuarios();
Console.ReadLine();
}
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio SOAP Actualizar Usuario
namespace ConsoleApp1
{
class doc
{
public class usuario
{
public String i_clave;
public String empresa;
public String jefe;
public String centro_costo;
public String grupo;
public String usuario_acl;
public String no_empleado;
public String appat;
public String apmat;
public String nombre;
public String mail;
public String cuenta_pagar;
public String cuenta_cobrar;
public String es_empleado;
public String es_director;
public String puesto;
public String foto;
public String estatus;
public String passwd;
}
public class admin
{
public String usuario;
public String passwd;
}
public static String actualizarUsuario(String token, usuario u, admin a)
{
String contentXML = "";
String response = "";
try
{
contentXML += "";
contentXML += " ";
contentXML += "";
contentXML += "";
contentXML += "" + token + " ";
contentXML += "";
contentXML += "" + u.i_clave + " ";
contentXML += "" + u.empresa + " ";
contentXML += "" + u.jefe + " ";
contentXML += "" + u.centro_costo + " ";
contentXML += "" + u.grupo + " ";
contentXML += "" + u.usuario_acl + " ";
contentXML += "" + u.no_empleado + " ";
contentXML += "" + u.appat + " ";
contentXML += "" + u.apmat + " ";
contentXML += "" + u.nombre + " ";
contentXML += "" + u.mail + " ";
contentXML += "" + u.cuenta_pagar + " ";
contentXML += "" + u.cuenta_cobrar + " ";
contentXML += "" + u.es_empleado + " ";
contentXML += "" + u.es_director + " ";
contentXML += "" + u.puesto + " ";
contentXML += "" + u.foto + " ";
contentXML += "" + u.estatus + " ";
contentXML += "" + u.passwd + " ";
contentXML += "";
contentXML += "" + a.usuario + " ";
contentXML += "" + a.passwd + " ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
Uri uri = new Uri("https://core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios");
WebRequest webRequest = WebRequest.Create(uri);
webRequest.ContentType = "text/xml;charset=UTF-8";
webRequest.ContentLength = contentXML.Length;
webRequest.Headers.Add( "SOAPAction", "http://radt.expenses.services/services/ActualizarUsuario");
webRequest.Method = "POST";
webRequest.GetRequestStream().Write(Encoding.UTF8.GetBytes(contentXML), 0, contentXML.Length);
using (WebResponse webResponse = webRequest.GetResponse())
{
using (StreamReader streamReader = new StreamReader(webResponse.GetResponseStream()))
{
response = streamReader.ReadToEnd();
}
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.ReadLine();
}
return response;
}
static void Main(string[] args)
{
usuario u = new usuario();
admin a = new admin();
String token = "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiwgImNvbm5lY3Rpb25faWQiOiJjbm5FeHBlbnNlc1NlbWlsbGFWMTAifQ==.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=";
u.i_clave = "137";
u.empresa = " ";
u.jefe = " ";
u.centro_costo = " ";
u.grupo = " ";
u.usuario_acl = " ";
u.no_empleado = " ";
u.appat = " ";
u.apmat = " ";
u.nombre = " ";
u.mail = " ";
u.cuenta_pagar = " ";
u.cuenta_cobrar = " ";
u.es_empleado = " ";
u.es_director = " ";
u.puesto = "Director de operaciones";
u.foto = " ";
u.estatus = " ";
u.passwd = " ";
a.usuario = "PRAMIREZMN";
a.passwd = "PRAMIREZMN";
Console.WriteLine(actualizarUsuario(token, u, a));
Console.ReadLine();
}
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST Actualizar Usuario
namespace RestExample
{
class RestExample
{
private static String url = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion{0}{1}";
private static void ReadStreamFromResponse(WebResponse response)
{
using (Stream responseStream = response.GetResponseStream())
using (StreamReader sr = new StreamReader(responseStream))
{
string strContent = sr.ReadToEnd();
Console.WriteLine(strContent);
}
}
private static void updateUsuario(String body)
{
var url = string.Format(RestExample.url, "/usuario", "");
var webrequest = (HttpWebRequest)System.Net.WebRequest.Create(url);
webrequest.Method = "PUT";
webrequest.Headers["Content-Type"] = "application/json";
webrequest.Headers["token"] = "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiB9.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=";
StreamWriter stream = new StreamWriter(webrequest.GetRequestStreamAsync().Result);
stream.Write(body);
stream.Flush();
Task task = Task.Factory.FromAsync(
webrequest.BeginGetResponse,
asyncResult => webrequest.EndGetResponse(asyncResult),
(object)null);
var responce = task.ContinueWith(t => ReadStreamFromResponse(t.Result));
}
static void Main(string[] args)
{
String body = "{" +
"\"i_clave\":\"113\"," +
"\"empresa\":null," +
"\"jefe\":null," +
"\"centro_costo\":null," +
"\"grupo\":null," +
"\"usuario_acl\":null," +
"\"no_empleado\":null," +
"\"appat\":null," +
"\"apmat\":null," +
"\"nombre\":null," +
"\"passwd\":null," +
"\"mail\":null," +
"\"cuenta_pagar\":null," +
"\"cuenta_cobrar\":null," +
"\"es_empleado\":null," +
"\"es_director\":null," +
"\"puesto\":\"Analista\"," +
"\"foto\":null," +
"\"estatus\":null," +
"\"admin\":{" +
"\"usuario\":\"PRAMIREZMN\"," +
"\"passwd\":\"PRAMIREZMN\"" +
"}" +
"}";
RestExample.updateUsuario(body);
Console.ReadLine();
}
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio SOAP Crear Concepto
namespace ConsoleApp1
{
class doc
{
public class concepto
{
public String i_clave;
public String nombre;
public String codigo;
public String cuenta;
public String cfdi;
public String pdf;
public String archivo;
public String arch_extranjero;
public String propina;
public String estatus;
}
public static String crearConcepto(String token, concepto c)
{
String contentXML = "";
String response = "";
try
{
contentXML += "";
contentXML += " ";
contentXML += "";
contentXML += "";
contentXML += "" + token + " ";
contentXML += "";
contentXML += "" + c.i_clave + " ";
contentXML += "" + c.nombre + " ";
contentXML += "" + c.codigo + " ";
contentXML += "" + c.cuenta + " ";
contentXML += "" + c.cfdi + " ";
contentXML += "" + c.pdf + " ";
contentXML += "" + c.archivo + " ";
contentXML += "" + c.arch_extranjero + " ";
contentXML += "" + c.propina + " ";
contentXML += "" + c.estatus + " ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
Uri uri = new Uri("https://core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios");
WebRequest webRequest = WebRequest.Create(uri);
webRequest.ContentType = "text/xml;charset=UTF-8";
webRequest.ContentLength = contentXML.Length;
webRequest.Headers.Add("SOAPAction", "http://radt.expenses.services/services/CrearConcepto");
webRequest.Method = "POST";
webRequest.GetRequestStream().Write(Encoding.UTF8.GetBytes(contentXML), 0, contentXML.Length);
using (WebResponse webResponse = webRequest.GetResponse())
{
using (StreamReader streamReader = new StreamReader(webResponse.GetResponseStream()))
{
response = streamReader.ReadToEnd();
}
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.ReadLine();
}
return response;
}
static void Main(string[] args)
{
concepto c = new concepto();
String token = "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiwgImNvbm5lY3Rpb25faWQiOiJjbm5FeHBlbnNlc1NlbWlsbGFWMTAifQ==.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=";
c.i_clave = "";
c.nombre = "Viajes";
c.codigo = "CPSH58";
c.cuenta = "CC-01267849";
c.cfdi = "S";
c.pdf = "N";
c.archivo = "N";
c.arch_extranjero = "N";
c.propina = "N";
c.estatus = "";
Console.WriteLine(crearConcepto(token, c));
Console.ReadLine();
}
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST Crear Concepto
namespace RestExample
{
class RestExample
{
private static String url = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion{0}{1}";
private static void ReadStreamFromResponse(WebResponse response)
{
using (Stream responseStream = response.GetResponseStream())
using (StreamReader sr = new StreamReader(responseStream))
{
string strContent = sr.ReadToEnd();
Console.WriteLine(strContent);
}
}
private static void createConcepto(String body)
{
var url = string.Format(RestExample.url, "/concepto", "");
var webrequest = (HttpWebRequest)System.Net.WebRequest.Create(url);
webrequest.Method = "POST";
webrequest.Headers["Content-Type"] = "application/json";
webrequest.Headers["token"] = "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiB9.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=";
StreamWriter stream = new StreamWriter(webrequest.GetRequestStreamAsync().Result);
stream.Write(body);
stream.Flush();
Task task = Task.Factory.FromAsync(
webrequest.BeginGetResponse,
asyncResult => webrequest.EndGetResponse(asyncResult),
(object)null);
var responce = task.ContinueWith(t => ReadStreamFromResponse(t.Result));
}
static void Main(string[] args)
{
String body = "{" +
"\"i_clave\":null," +
"\"nombre\":\"Viajes por representacion\"," +
"\"codigo\":\"CPSH10\"," +
"\"cuenta\":\"CC-01267847\"," +
"\"cfdi\":\"N\"," +
"\"pdf\":\"N\"," +
"\"archivo\":\"N\"," +
"\"arch_extranjero\":\"N\"," +
"\"propina\":\"N\"," +
"\"estatus\":null," +
"}";
RestExample.createConcepto(body);
Console.ReadLine();
}
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio SOAP Concepto
public static String concepto(String token, String id_concepto)
{
String contentXML = "";
String response = "";
try
{
contentXML += "";
contentXML += " ";
contentXML += "";
contentXML += "";
contentXML += "" + token + " ";
contentXML += "" + id_concepto + " ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
Uri uri = new Uri("https://core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios");
WebRequest webRequest = WebRequest.Create(uri);
webRequest.ContentType = "text/xml;charset=UTF-8";
webRequest.ContentLength = contentXML.Length;
webRequest.Headers.Add("SOAPAction", "http://radt.expenses.services/services/Concepto");
webRequest.Method = "POST";
webRequest.GetRequestStream().Write(Encoding.UTF8.GetBytes(contentXML), 0, contentXML.Length);
using (WebResponse webResponse = webRequest.GetResponse())
{
using (StreamReader streamReader = new StreamReader(webResponse.GetResponseStream()))
{
response = streamReader.ReadToEnd();
}
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.ReadLine();
}
return response;
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST Concepto
namespace RestExample
{
class RestExample
{
private static String url = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion{0}{1}";
private static void ReadStreamFromResponse(WebResponse response)
{
using (Stream responseStream = response.GetResponseStream())
using (StreamReader sr = new StreamReader(responseStream))
{
string strContent = sr.ReadToEnd();
Console.WriteLine(strContent);
}
}
private static void getConcepto(String id)
{
var url = string.Format(RestExample.url, "/concepto/", id);
var webrequest = (HttpWebRequest)System.Net.WebRequest.Create(url);
webrequest.Method = "GET";
webrequest.Headers["Content-Type"] = "application/json";
webrequest.Headers["token"] = "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiB9.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=";
Task task = Task.Factory.FromAsync(
webrequest.BeginGetResponse,
asyncResult => webrequest.EndGetResponse(asyncResult),
(object)null);
var responce = task.ContinueWith(t => ReadStreamFromResponse(t.Result));
}
static void Main(string[] args)
{
RestExample.getConcepto("17");
Console.ReadLine();
}
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio SOAP Conceptos
public static String conceptos(String token)
{
String contentXML = "";
String response = "";
try
{
contentXML += "";
contentXML += " ";
contentXML += "";
contentXML += "";
contentXML += "" + token + " ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
Uri uri = new Uri("https://core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios");
WebRequest webRequest = WebRequest.Create(uri);
webRequest.ContentType = "text/xml;charset=UTF-8";
webRequest.ContentLength = contentXML.Length;
webRequest.Headers.Add("SOAPAction", "http://radt.expenses.services/services/Conceptos");
webRequest.Method = "POST";
webRequest.GetRequestStream().Write(Encoding.UTF8.GetBytes(contentXML), 0, contentXML.Length);
using (WebResponse webResponse = webRequest.GetResponse())
{
using (StreamReader streamReader = new StreamReader(webResponse.GetResponseStream()))
{
response = streamReader.ReadToEnd();
}
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.ReadLine();
}
return response;
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST Conceptos
namespace RestExample
{
class RestExample
{
private static String url = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion{0}{1}";
private static void ReadStreamFromResponse(WebResponse response)
{
using (Stream responseStream = response.GetResponseStream())
using (StreamReader sr = new StreamReader(responseStream))
{
string strContent = sr.ReadToEnd();
Console.WriteLine(strContent);
}
}
private static void getConceptos()
{
var url = string.Format(RestExample.url, "/conceptos", "");
var webrequest = (HttpWebRequest)System.Net.WebRequest.Create(url);
webrequest.Method = "GET";
webrequest.Headers["Content-Type"] = "application/json";
webrequest.Headers["token"] = "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiB9.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=";
Task task = Task.Factory.FromAsync(
webrequest.BeginGetResponse,
asyncResult => webrequest.EndGetResponse(asyncResult),
(object)null);
var responce = task.ContinueWith(t => ReadStreamFromResponse(t.Result));
}
static void Main(string[] args)
{
RestExample.getConceptos();
Console.ReadLine();
}
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio SOAP Actualizar Conceptos
namespace ConsoleApp1
{
class doc
{
public class concepto
{
public String i_clave;
public String nombre;
public String codigo;
public String cuenta;
public String cfdi;
public String pdf;
public String archivo;
public String arch_extranjero;
public String propina;
public String estatus;
}
public static String actualizarConcepto(String token, concepto c)
{
String contentXML = "";
String response = "";
try
{
contentXML += "";
contentXML += " ";
contentXML += "";
contentXML += "";
contentXML += "" + token + " ";
contentXML += "";
contentXML += "" + c.i_clave + " ";
contentXML += "" + c.nombre + " ";
contentXML += "" + c.codigo + " ";
contentXML += "" + c.cuenta + " ";
contentXML += "" + c.cfdi + " ";
contentXML += "" + c.pdf + " ";
contentXML += "" + c.archivo + " ";
contentXML += "" + c.arch_extranjero + " ";
contentXML += "" + c.propina + " ";
contentXML += "" + c.estatus + " ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
Uri uri = new Uri("https://core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios");
WebRequest webRequest = WebRequest.Create(uri);
webRequest.ContentType = "text/xml;charset=UTF-8";
webRequest.ContentLength = contentXML.Length;
webRequest.Headers.Add("SOAPAction", "http://radt.expenses.services/services/ActualizarConcepto");
webRequest.Method = "POST";
webRequest.GetRequestStream().Write(Encoding.UTF8.GetBytes(contentXML), 0, contentXML.Length);
using (WebResponse webResponse = webRequest.GetResponse())
{
using (StreamReader streamReader = new StreamReader(webResponse.GetResponseStream()))
{
response = streamReader.ReadToEnd();
}
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.ReadLine();
}
return response;
}
static void Main(string[] args)
{
concepto c = new concepto();
String token = "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiwgImNvbm5lY3Rpb25faWQiOiJjbm5FeHBlbnNlc1NlbWlsbGFWMTAifQ==.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=";
c.i_clave = "5";
c.nombre = "Alimentos por representacion";
c.codigo = "";
c.cuenta = "";
c.cfdi = "";
c.pdf = "";
c.archivo = "";
c.arch_extranjero = "";
c.propina = "";
c.estatus = "";
Console.WriteLine(actualizarConcepto(token, c));
Console.ReadLine();
}
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST Actualizar Concepto
namespace RestExample
{
class RestExample
{
private static String url = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion{0}{1}";
private static void ReadStreamFromResponse(WebResponse response)
{
using (Stream responseStream = response.GetResponseStream())
using (StreamReader sr = new StreamReader(responseStream))
{
string strContent = sr.ReadToEnd();
Console.WriteLine(strContent);
}
}
private static void updateConcepto(String body)
{
var url = string.Format(RestExample.url, "/concepto", "");
var webrequest = (HttpWebRequest)System.Net.WebRequest.Create(url);
webrequest.Method = "PUT";
webrequest.Headers["Content-Type"] = "application/json";
webrequest.Headers["token"] = "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiB9.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=";
StreamWriter stream = new StreamWriter(webrequest.GetRequestStreamAsync().Result);
stream.Write(body);
stream.Flush();
Task task = Task.Factory.FromAsync(
webrequest.BeginGetResponse,
asyncResult => webrequest.EndGetResponse(asyncResult),
(object)null);
var responce = task.ContinueWith(t => ReadStreamFromResponse(t.Result));
}
static void Main(string[] args)
{
String body = "{" +
"\"i_clave\":\"1\"," +
"\"nombre\":\"Viajes foraneos\"," +
"\"codigo\":null," +
"\"cuenta\":null," +
"\"cfdi\":null," +
"\"pdf\":null," +
"\"archivo\":null," +
"\"arch_extranjero\":null," +
"\"propina\":null," +
"\"estatus\":null," +
"}";
RestExample.updateConcepto(body);
Console.ReadLine();
}
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio SOAP Crear Centro de Costos
namespace ConsoleApp1
{
class doc
{
public class ceco
{
public String i_clave;
public String empresa;
public String divisa;
public String gerente;
public String nombre;
public String codigo;
public String estatus;
}
public static String crearCentroCostos(String token, ceco c)
{
String contentXML = "";
String response = "";
try
{
contentXML += "";
contentXML += " ";
contentXML += "";
contentXML += "";
contentXML += "" + token + " ";
contentXML += "";
contentXML += "" + c.i_clave + " ";
contentXML += "" + c.empresa + " ";
contentXML += "" + c.divisa + " ";
contentXML += "" + c.gerente + " ";
contentXML += "" + c.nombre + " ";
contentXML += "" + c.codigo + " ";
contentXML += "" + c.estatus + " ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
Uri uri = new Uri("https://core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios");
WebRequest webRequest = WebRequest.Create(uri);
webRequest.ContentType = "text/xml;charset=UTF-8";
webRequest.ContentLength = contentXML.Length;
webRequest.Headers.Add("SOAPAction", "http://radt.expenses.services/services/CrearCentroCostos");
webRequest.Method = "POST";
webRequest.GetRequestStream().Write(Encoding.UTF8.GetBytes(contentXML), 0, contentXML.Length);
using (WebResponse webResponse = webRequest.GetResponse())
{
using (StreamReader streamReader = new StreamReader(webResponse.GetResponseStream()))
{
response = streamReader.ReadToEnd();
}
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.ReadLine();
}
return response;
}
static void Main(string[] args)
{
ceco c = new ceco();
String token = "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiwgImNvbm5lY3Rpb25faWQiOiJjbm5FeHBlbnNlc1NlbWlsbGFWMTAifQ==.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=";
c.i_clave = "";
c.empresa = "K001";
c.divisa = "USD";
c.gerente = "802345";
c.nombre = "Servicios";
c.codigo = "K0010070";
c.estatus = "";
Console.WriteLine(crearCentroCostos(token, c));
Console.ReadLine();
}
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST Crear Centro de Costos
namespace RestExample
{
class RestExample
{
private static String url = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion{0}{1}";
private static void ReadStreamFromResponse(WebResponse response)
{
using (Stream responseStream = response.GetResponseStream())
using (StreamReader sr = new StreamReader(responseStream))
{
string strContent = sr.ReadToEnd();
Console.WriteLine(strContent);
}
}
private static void createCeCo(String body)
{
var url = string.Format(RestExample.url, "/centro-costos", "");
var webrequest = (HttpWebRequest)System.Net.WebRequest.Create(url);
webrequest.Method = "POST";
webrequest.Headers["Content-Type"] = "application/json";
webrequest.Headers["token"] = "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiB9.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=";
StreamWriter stream = new StreamWriter(webrequest.GetRequestStreamAsync().Result);
stream.Write(body);
stream.Flush();
Task task = Task.Factory.FromAsync(
webrequest.BeginGetResponse,
asyncResult => webrequest.EndGetResponse(asyncResult),
(object)null);
var responce = task.ContinueWith(t => ReadStreamFromResponse(t.Result));
}
static void Main(string[] args)
{
String body = "{" +
"\"i_clave\":null," +
"\"empresa\":\"K010\"," +
"\"divisa\":\"MXN\"," +
"\"gerente\":\"802345\"," +
"\"nombre\":\"Direccion\"," +
"\"codigo\":\"K0010061\"," +
"\"estatus\":null," +
"}";
RestExample.createCeCo(body);
Console.ReadLine();
}
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio SOAP Centro de Costos
public static String centroCostos(String token, String id_centro_costos)
{
String contentXML = "";
String response = "";
try
{
contentXML += "";
contentXML += " ";
contentXML += "";
contentXML += "";
contentXML += "" + token + " ";
contentXML += "" + id_centro_costos + " ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
Uri uri = new Uri("https://core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios");
WebRequest webRequest = WebRequest.Create(uri);
webRequest.ContentType = "text/xml;charset=UTF-8";
webRequest.ContentLength = contentXML.Length;
webRequest.Headers.Add("SOAPAction", "http://radt.expenses.services/services/CentroCostos");
webRequest.Method = "POST";
webRequest.GetRequestStream().Write(Encoding.UTF8.GetBytes(contentXML), 0, contentXML.Length);
using (WebResponse webResponse = webRequest.GetResponse())
{
using (StreamReader streamReader = new StreamReader(webResponse.GetResponseStream()))
{
response = streamReader.ReadToEnd();
}
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.ReadLine();
}
return response;
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST Centro de Costos
namespace RestExample
{
class RestExample
{
private static String url = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion{0}{1}";
private static void ReadStreamFromResponse(WebResponse response)
{
using (Stream responseStream = response.GetResponseStream())
using (StreamReader sr = new StreamReader(responseStream))
{
string strContent = sr.ReadToEnd();
Console.WriteLine(strContent);
}
}
private static void getCeCo(String id)
{
var url = string.Format(RestExample.url, "/centro-costos/", id);
var webrequest = (HttpWebRequest)System.Net.WebRequest.Create(url);
webrequest.Method = "GET";
webrequest.Headers["Content-Type"] = "application/json";
webrequest.Headers["token"] = "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiB9.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=";
Task task = Task.Factory.FromAsync(
webrequest.BeginGetResponse,
asyncResult => webrequest.EndGetResponse(asyncResult),
(object)null);
var responce = task.ContinueWith(t => ReadStreamFromResponse(t.Result));
}
static void Main(string[] args)
{
RestExample.getCeCo("1");
Console.ReadLine();
}
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST Comprobantes pendientes
public static String centrosCostos(String token)
{
String contentXML = "";
String response = "";
try
{
contentXML += "";
contentXML += " ";
contentXML += "";
contentXML += "";
contentXML += "" + token + " ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
Uri uri = new Uri("https://core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios");
WebRequest webRequest = WebRequest.Create(uri);
webRequest.ContentType = "text/xml;charset=UTF-8";
webRequest.ContentLength = contentXML.Length;
webRequest.Headers.Add("SOAPAction", "http://radt.expenses.services/services/CentrosCostos");
webRequest.Method = "POST";
webRequest.GetRequestStream().Write(Encoding.UTF8.GetBytes(contentXML), 0, contentXML.Length);
using (WebResponse webResponse = webRequest.GetResponse())
{
using (StreamReader streamReader = new StreamReader(webResponse.GetResponseStream()))
{
response = streamReader.ReadToEnd();
}
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.ReadLine();
}
return response;
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST Centros de Costos
namespace RestExample
{
class RestExample
{
private static String url = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion{0}{1}";
private static void ReadStreamFromResponse(WebResponse response)
{
using (Stream responseStream = response.GetResponseStream())
using (StreamReader sr = new StreamReader(responseStream))
{
string strContent = sr.ReadToEnd();
Console.WriteLine(strContent);
}
}
private static void getCeCos()
{
var url = string.Format(RestExample.url, "/centros-costos", "");
var webrequest = (HttpWebRequest)System.Net.WebRequest.Create(url);
webrequest.Method = "GET";
webrequest.Headers["Content-Type"] = "application/json";
webrequest.Headers["token"] = "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiB9.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=";
Task task = Task.Factory.FromAsync(
webrequest.BeginGetResponse,
asyncResult => webrequest.EndGetResponse(asyncResult),
(object)null);
var responce = task.ContinueWith(t => ReadStreamFromResponse(t.Result));
}
static void Main(string[] args)
{
RestExample.getCeCos();
Console.ReadLine();
}
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio SOAP Actualizar Centros de Costos
namespace ConsoleApp1
{
class doc
{
public class ceco
{
public String i_clave;
public String empresa;
public String divisa;
public String gerente;
public String nombre;
public String codigo;
public String estatus;
}
public static String actualizarCentroCostos(String token, ceco c)
{
String contentXML = "";
String response = "";
try
{
contentXML += "";
contentXML += " ";
contentXML += "";
contentXML += "";
contentXML += "" + token + " ";
contentXML += "";
contentXML += "" + c.i_clave + " ";
contentXML += "" + c.empresa + " ";
contentXML += "" + c.divisa + " ";
contentXML += "" + c.gerente + " ";
contentXML += "" + c.nombre + " ";
contentXML += "" + c.codigo + " ";
contentXML += "" + c.estatus + " ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
Uri uri = new Uri("https://core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios");
WebRequest webRequest = WebRequest.Create(uri);
webRequest.ContentType = "text/xml;charset=UTF-8";
webRequest.ContentLength = contentXML.Length;
webRequest.Headers.Add("SOAPAction", "http://radt.expenses.services/services/ActualizarCentroCostos");
webRequest.Method = "POST";
webRequest.GetRequestStream().Write(Encoding.UTF8.GetBytes(contentXML), 0, contentXML.Length);
using (WebResponse webResponse = webRequest.GetResponse())
{
using (StreamReader streamReader = new StreamReader(webResponse.GetResponseStream()))
{
response = streamReader.ReadToEnd();
}
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.ReadLine();
}
return response;
}
static void Main(string[] args)
{
ceco c = new ceco();
String token = "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiwgImNvbm5lY3Rpb25faWQiOiJjbm5FeHBlbnNlc1NlbWlsbGFWMTAifQ==.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=";
c.i_clave = "21";
c.empresa = "";
c.divisa = "";
c.gerente = "";
c.nombre = "Ventas mayoreo";
c.codigo = "";
c.estatus = "";
Console.WriteLine(actualizarCentroCostos(token, c));
Console.ReadLine();
}
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST Actualizar Centro de Costos
namespace RestExample
{
class RestExample
{
private static String url = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion{0}{1}";
private static void ReadStreamFromResponse(WebResponse response)
{
using (Stream responseStream = response.GetResponseStream())
using (StreamReader sr = new StreamReader(responseStream))
{
string strContent = sr.ReadToEnd();
Console.WriteLine(strContent);
}
}
private static void updateCeCo(String body)
{
var url = string.Format(RestExample.url, "/centro-costos", "");
var webrequest = (HttpWebRequest)System.Net.WebRequest.Create(url);
webrequest.Method = "PUT";
webrequest.Headers["Content-Type"] = "application/json";
webrequest.Headers["token"] = "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiB9.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=";
StreamWriter stream = new StreamWriter(webrequest.GetRequestStreamAsync().Result);
stream.Write(body);
stream.Flush();
Task task = Task.Factory.FromAsync(
webrequest.BeginGetResponse,
asyncResult => webrequest.EndGetResponse(asyncResult),
(object)null);
var responce = task.ContinueWith(t => ReadStreamFromResponse(t.Result));
}
static void Main(string[] args)
{
String body = "{" +
"\"i_clave\":\"1\"," +
"\"empresa\":\"K010\"," +
"\"divisa\":\"MXN\"," +
"\"gerente\":\"802345\"," +
"\"nombre\":\"Colocacion\"," +
"\"codigo\":\"K0010061\"," +
"\"estatus\":null," +
"}";
RestExample.updateCeCo(body);
Console.ReadLine();
}
}
}
La siguiente función describe la invocación al servicio de e-Xpenses para solicitar la actualizacion de un comprobante
public static String ActualizaComprobante(String token,String id_comprobante)
{
String uri = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios";
String contentXML = "";
String response = null;
HttpURLConnection connection = null;
contentXML += "";
contentXML += " ";
contentXML += "";
contentXML += "";
contentXML += "" + token + " ";
contentXML += "" + id_comprobante + " ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
try
{
URL url = new URL(uri);
connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
connection.setDoOutput(true);
connection.setRequestProperty("SOAPAction", "http://radt.expenses.services/services/ActualizaComprobante");
if (contentXML != null)
{
connection.setRequestProperty("Content-Length", Integer.toString(contentXML.length()));
Writer wr = new OutputStreamWriter(connection.getOutputStream(), StandardCharsets.UTF_8);
wr.write(contentXML);
wr.flush();
wr.close();
}
int responseCode = connection.getResponseCode();
if(responseCode == 200 || responseCode == 401 || responseCode == 409)
{
StringBuffer buffer = new StringBuffer();
BufferedReader reader;
if (responseCode == 200)
{
reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
}
else
reader = new BufferedReader(new InputStreamReader(connection.getErrorStream(), "UTF-8"));
String linea;
while((linea = reader.readLine()) != null)
{
buffer.append(linea);
}
response = buffer.toString();
} else if( responseCode == 400 )
{
throw new RuntimeException("Error 400: Bad Request");
} else
{
throw new RuntimeException("Error: ResponseCode = " + responseCode);
}
}
catch(Exception e)
{
response = null;
throw new RuntimeException( e.getMessage() );
}
return response;
}
La siguiente función describe la invocación a e-Xpenses para solicitar el servicio REST de la actualizacion de un comprobante
public class UpdateComprobacion {
private static final String URLBase = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion";
public static void updateComprobacion(String id) throws ClientProtocolException, IOException {
@SuppressWarnings("deprecation")
String petition = UpdateComprobacion.URLBase + "/comprobacion/" + id;
HttpClient client = new DefaultHttpClient();
HttpPut request = new HttpPut(petition);
request.setHeader("Content-Type", "application/json");
request.setHeader("token", "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiwgImNvbm5lY3Rpb25faWQiOiJjbm5FeHBlbnNlc1NlbWlsbGFWMTAifQ==.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=");
HttpResponse response = client.execute(request);
BufferedReader rd = new BufferedReader (new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
}
public static void main(String[] args) throws ClientProtocolException, IOException {
UpdateComprobacion.updateComprobacion("1");
}
}
La siguiente función describe la invocación al servicio de e-Xpenses para comprobante pendiente
public static String ComprobantePendiente(String token,String id_comprobante)
{
String uri = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios";
String contentXML = "";
String response = null;
HttpURLConnection connection = null;
contentXML += "";
contentXML += " ";
contentXML += "";
contentXML += "";
contentXML += "" + token + " ";
contentXML += "" + id_comprobante + " ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
try
{
URL url = new URL(uri);
connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
connection.setDoOutput(true);
connection.setRequestProperty("SOAPAction", "http://radt.expenses.services/services/ComprobantePendiente");
if (contentXML != null)
{
connection.setRequestProperty("Content-Length", Integer.toString(contentXML.length()));
Writer wr = new OutputStreamWriter(connection.getOutputStream(), StandardCharsets.UTF_8);
wr.write(contentXML);
wr.flush();
wr.close();
}
int responseCode = connection.getResponseCode();
if(responseCode == 200 || responseCode == 401 || responseCode == 409)
{
StringBuffer buffer = new StringBuffer();
BufferedReader reader;
if (responseCode == 200)
{
reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
}
else
reader = new BufferedReader(new InputStreamReader(connection.getErrorStream(), "UTF-8"));
String linea;
while((linea = reader.readLine()) != null)
{
buffer.append(linea);
}
response = buffer.toString();
} else if( responseCode == 400 )
{
throw new RuntimeException("Error 400: Bad Request");
} else
{
throw new RuntimeException("Error: ResponseCode = " + responseCode);
}
}
catch(Exception e)
{
response = null;
throw new RuntimeException( e.getMessage() );
}
return response;
}
La siguiente función describe la invocación al servicio REST de e-Xpenses para comprobante pendiente
public class GetComprobacion {
private static final String URLBase = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion";
public static void getComprobacion(String id) throws ClientProtocolException, IOException {
@SuppressWarnings("deprecation")
String petition = GetComprobacion.URLBase + "/concepto/" + id;
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(petition);
request.setHeader("Content-Type", "application/json");
request.setHeader("token", "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiwgImNvbm5lY3Rpb25faWQiOiJjbm5FeHBlbnNlc1NlbWlsbGFWMTAifQ==.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=");
HttpResponse response = client.execute(request);
BufferedReader rd = new BufferedReader (new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
}
public static void main(String[] args) throws ClientProtocolException, IOException {
GetComprobacion.getComprobacion("1");
}
}
La siguiente función describe la invocación al servicio de e-Xpenses para solicitar Comprobantes pendientes
public static String ComprobantesPendientes(String token)
{
String uri = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios";
String contentXML = "";
String response = null;
HttpURLConnection connection = null;
contentXML += "";
contentXML += " ";
contentXML += "";
contentXML += "";
contentXML += "" + token + " ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
try
{
URL url = new URL(uri);
connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
connection.setDoOutput(true);
connection.setRequestProperty("SOAPAction", "http://radt.expenses.services/services/ComprobantesPendientes");
if (contentXML != null)
{
connection.setRequestProperty("Content-Length", Integer.toString(contentXML.length()));
Writer wr = new OutputStreamWriter(connection.getOutputStream(), StandardCharsets.UTF_8);
wr.write(contentXML);
wr.flush();
wr.close();
}
int responseCode = connection.getResponseCode();
if(responseCode == 200 || responseCode == 401 || responseCode == 409)
{
StringBuffer buffer = new StringBuffer();
BufferedReader reader;
if (responseCode == 200)
{
reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
}
else
reader = new BufferedReader(new InputStreamReader(connection.getErrorStream(), "UTF-8"));
String linea;
while((linea = reader.readLine()) != null)
{
buffer.append(linea);
}
response = buffer.toString();
} else if( responseCode == 400 )
{
throw new RuntimeException("Error 400: Bad Request");
} else
{
throw new RuntimeException("Error: ResponseCode = " + responseCode);
}
}
catch(Exception e)
{
response = null;
throw new RuntimeException( e.getMessage() );
}
return response;
}
La siguiente función describe la invocación al servicio de e-Xpenses para solicitar Comprobantes pendientes
public class GetComprobaciones{
private static final String URLBase = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion";
public static void getServices() throws ClientProtocolException, IOException {
@SuppressWarnings("deprecation")
String petition = GetComprobaciones.URLBase + "/conceptos";
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(petition);
request.setHeader("Content-Type", "application/json");
request.setHeader("token", "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiwgImNvbm5lY3Rpb25faWQiOiJjbm5FeHBlbnNlc1NlbWlsbGFWMTAifQ==.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=");
HttpResponse response = client.execute(request);
BufferedReader rd = new BufferedReader (new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
}
public static void main(String[] args) throws ClientProtocolException, IOException {
GetComprobaciones.getServices();
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio SOAP Crear Usuario
public class CrearUsuario {
public static class usuario{
public String i_clave;
public String empresa;
public String jefe;
public String centro_costo;
public String grupo;
public String usuario_acl;
public String no_empleado;
public String appat;
public String apmat;
public String nombre;
public String mail;
public String cuenta_pagar;
public String cuenta_cobrar;
public String es_empleado;
public String es_director;
public String puesto;
public String foto;
public String estatus;
public String passwd;
}
public static class admin {
public String usuario;
public String passwd;
}
public static String CreaUsuario(String token, usuario u, admin a)
{
String uri = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios";
String contentXML = "";
String response = null;
HttpURLConnection connection = null;
contentXML += "";
contentXML += " ";
contentXML += "";
contentXML += "";
contentXML += "" + token + " ";
contentXML +="";
contentXML +=""+u.i_clave+" ";
contentXML +=""+u.empresa+" ";
contentXML +=""+u.jefe+" ";
contentXML +=""+u.centro_costo+" ";
contentXML +=""+ u.grupo +" ";
contentXML +=""+u.usuario_acl+" ";
contentXML +=""+u.no_empleado+" ";
contentXML +=""+u.appat+" ";
contentXML +=""+u.apmat+" ";
contentXML +=""+u.nombre+" ";
contentXML +=""+u.mail+" ";
contentXML +=""+u.cuenta_pagar+" ";
contentXML +=""+u.cuenta_cobrar+" ";
contentXML +=""+u.es_empleado+" ";
contentXML +=""+u.es_director+" ";
contentXML +=""+u.puesto+" ";
contentXML +=""+u.foto+" ";
contentXML +=""+u.estatus+" ";
contentXML +=""+u.passwd+" ";
contentXML +="";
contentXML +=""+a.usuario+" ";
contentXML +=""+a.passwd+" ";
contentXML +=" ";
contentXML +=" ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
try
{
URL url = new URL(uri);
connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
connection.setDoOutput(true);
connection.setRequestProperty("SOAPAction", "http://radt.expenses.services/services/CrearUsuario");
if (contentXML != null)
{
connection.setRequestProperty("Content-Length", Integer.toString(contentXML.length()));
Writer wr = new OutputStreamWriter(connection.getOutputStream(), StandardCharsets.UTF_8);
wr.write(contentXML);
wr.flush();
wr.close();
}
int responseCode = connection.getResponseCode();
if(responseCode == 200 || responseCode == 401 || responseCode == 409)
{
StringBuffer buffer = new StringBuffer();
BufferedReader reader;
if (responseCode == 200)
{
reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
}
else
reader = new BufferedReader(new InputStreamReader(connection.getErrorStream(), "UTF-8"));
String linea;
while((linea = reader.readLine()) != null)
{
buffer.append(linea);
}
response = buffer.toString();
} else if( responseCode == 400 )
{
throw new RuntimeException("Error 400: Bad Request");
} else
{
throw new RuntimeException("Error: ResponseCode = " + responseCode);
}
}
catch(Exception e)
{
response = null;
throw new RuntimeException( e.getMessage() );
}
return response;
}
public static void main(String[] args) {
usuario u = new usuario();
admin a = new admin();
String token="eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiwgImNvbm5lY3Rpb25faWQiOiJjbm5FeHBlbnNlc1NlbWlsbGFWMTAifQ==.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=";
u.i_clave="";
u.empresa="K001";
u.jefe="802345";
u.centro_costo="K0010055";
u.grupo="Empleados";
u.usuario_acl="YTREJOPEMN44";
u.no_empleado="12345678913";
u.appat="Trejo";
u.apmat="Perez";
u.nombre="Yahuitl Tonatiu";
u.mail="yahuitl_trejo_perez@hotmail.com";
u.cuenta_pagar="0000000";
u.cuenta_cobrar="0000000";
u.es_empleado="S";
u.es_director="N";
u.puesto="Lider supremo";
u.foto="";
u.estatus="";
u.passwd="12345678";
a.usuario="PRAMIREZMN";
a.passwd="PRAMIREZMN";
CreaUsuario(token, u, a);
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio de Crear Usuario
public class CreateUsuario {
private static final String URLBase = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion";
public static void CreateUsuario(String body) throws ClientProtocolException, IOException {
@SuppressWarnings("deprecation")
String petition = CreateUsuario.URLBase + "/usuario";
HttpClient client = new DefaultHttpClient();
HttpPost request = new HttpPost(petition);
StringEntity params = new StringEntity(body);
request.setEntity(params);
request.setHeader("Accept", "application/json");
request.setHeader("Content-Type", "application/json");
request.setHeader("token", "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiwgImNvbm5lY3Rpb25faWQiOiJjbm5FeHBlbnNlc1NlbWlsbGFWMTAifQ==.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=");
HttpResponse response = client.execute(request);
BufferedReader rd = new BufferedReader (new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
}
public static void main(String[] args) throws ClientProtocolException, IOException {
String body =
"{" +
"\"i_clave\":null," +
"\"empresa\":\"K001\"," +
"\"jefe\":\"802345\"," +
"\"centro_costo\":\"K0010055\"," +
"\"grupo\":\"Empleados\"," +
"\"usuario_acl\":\"YTREJOPEMN44\"," +
"\"no_empleado\":\"12345678913\"," +
"\"appat\":\"Trejo\"," +
"\"apmat\":\"Perez\"," +
"\"nombre\":\"Yahuitl Tonatiu\"," +
"\"passwd\":\"root\"," +
"\"mail\":\"yahuitl_trejo_perez@hotmail.com\"," +
"\"cuenta_pagar\":\"0000000\"," +
"\"cuenta_cobrar\":\"0000000\"," +
"\"es_empleado\":\"S\"," +
"\"es_director\":\"N\"," +
"\"puesto\":\"Lider supremo :v\"," +
"\"foto\":null," +
"\"estatus\":null," +
"\"admin\":{" +
"\"usuario\":\"PRAMIREZMN\"," +
"\"passwd\":\"PRAMIREZMN\"" +
"}" +
"}";
CreateUsuario.CreateUsuario(body);
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio SOAP Usuario
public static String usuario(String token,String id_usuario)
{
String uri = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios";
String contentXML = "";
String response = null;
HttpURLConnection connection = null;
contentXML += "";
contentXML += " ";
contentXML += "";
contentXML += "";
contentXML += "" + token + " ";
contentXML += "" + id_usuario + " ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
try
{
URL url = new URL(uri);
connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
connection.setDoOutput(true);
connection.setRequestProperty("SOAPAction", "http://radt.expenses.services/services/Usuario");
if (contentXML != null)
{
connection.setRequestProperty("Content-Length", Integer.toString(contentXML.length()));
Writer wr = new OutputStreamWriter(connection.getOutputStream(), StandardCharsets.UTF_8);
wr.write(contentXML);
wr.flush();
wr.close();
}
int responseCode = connection.getResponseCode();
if(responseCode == 200 || responseCode == 401 || responseCode == 409)
{
StringBuffer buffer = new StringBuffer();
BufferedReader reader;
if (responseCode == 200)
{
reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
}
else
reader = new BufferedReader(new InputStreamReader(connection.getErrorStream(), "UTF-8"));
String linea;
while((linea = reader.readLine()) != null)
{
buffer.append(linea);
}
response = buffer.toString();
} else if( responseCode == 400 )
{
throw new RuntimeException("Error 400: Bad Request");
} else
{
throw new RuntimeException("Error: ResponseCode = " + responseCode);
}
}
catch(Exception e)
{
response = null;
throw new RuntimeException( e.getMessage() );
}
return response;
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio de Usuario
public class GetUsuario {
private static final String URLBase = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion";
public static void getUsuario(String id) throws ClientProtocolException, IOException {
@SuppressWarnings("deprecation")
String petition = GetUsuario.URLBase + "/usuario/" + id;
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(petition);
request.setHeader("Content-Type", "application/json");
request.setHeader("token", "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiwgImNvbm5lY3Rpb25faWQiOiJjbm5FeHBlbnNlc1NlbWlsbGFWMTAifQ==.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=");
HttpResponse response = client.execute(request);
BufferedReader rd = new BufferedReader (new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
}
public static void main(String[] args) throws ClientProtocolException, IOException {
GetUsuario.getUsuario("131");
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio SOAP Usuarios
public static String usuarios(String token)
{
String uri = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios";
String contentXML = "";
String response = null;
HttpURLConnection connection = null;
contentXML += "";
contentXML += " ";
contentXML += "";
contentXML += "";
contentXML += "" + token + " ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
try
{
URL url = new URL(uri);
connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
connection.setDoOutput(true);
connection.setRequestProperty("SOAPAction", "http://radt.expenses.services/services/Usuarios");
if (contentXML != null)
{
connection.setRequestProperty("Content-Length", Integer.toString(contentXML.length()));
Writer wr = new OutputStreamWriter(connection.getOutputStream(), StandardCharsets.UTF_8);
wr.write(contentXML);
wr.flush();
wr.close();
}
int responseCode = connection.getResponseCode();
if(responseCode == 200 || responseCode == 401 || responseCode == 409)
{
StringBuffer buffer = new StringBuffer();
BufferedReader reader;
if (responseCode == 200)
{
reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
}
else
reader = new BufferedReader(new InputStreamReader(connection.getErrorStream(), "UTF-8"));
String linea;
while((linea = reader.readLine()) != null)
{
buffer.append(linea);
}
response = buffer.toString();
} else if( responseCode == 400 )
{
throw new RuntimeException("Error 400: Bad Request");
} else
{
throw new RuntimeException("Error: ResponseCode = " + responseCode);
}
}
catch(Exception e)
{
response = null;
throw new RuntimeException( e.getMessage() );
}
return response;
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio de Usuarios
public class GetUsuarios {
private static final String URLBase = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion";
public static void getUsuarios () throws ClientProtocolException, IOException {
@SuppressWarnings("deprecation")
String petition = GetUsuarios.URLBase + "/usuarios";
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(petition);
request.setHeader("Content-Type", "application/json");
request.setHeader("token", "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiwgImNvbm5lY3Rpb25faWQiOiJjbm5FeHBlbnNlc1NlbWlsbGFWMTAifQ==.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=");
HttpResponse response = client.execute(request);
BufferedReader rd = new BufferedReader (new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
}
public static void main(String[] args) throws ClientProtocolException, IOException {
GetUsuarios.getUsuarios();
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio SOAP Actualizar Usuario
public class actualizarUsuario {
public static class usuario{
public String i_clave;
public String empresa;
public String jefe;
public String centro_costo;
public String grupo;
public String usuario_acl;
public String no_empleado;
public String appat;
public String apmat;
public String nombre;
public String mail;
public String cuenta_pagar;
public String cuenta_cobrar;
public String es_empleado;
public String es_director;
public String puesto;
public String foto;
public String estatus;
public String passwd;
}
public static class admin {
public String usuario;
public String passwd;
}
public static String actualizarUsuario(String token, usuario u, admin a)
{
String uri = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios";
String contentXML = "";
String response = null;
HttpURLConnection connection = null;
contentXML += "";
contentXML += " ";
contentXML += "";
contentXML += "";
contentXML += "" + token + " ";
contentXML +="";
contentXML +=""+u.i_clave+" ";
contentXML +=""+u.empresa+" ";
contentXML +=""+u.jefe+" ";
contentXML +=""+u.centro_costo+" ";
contentXML +=""+ u.grupo +" ";
contentXML +=""+u.usuario_acl+" ";
contentXML +=""+u.no_empleado+" ";
contentXML +=""+u.appat+" ";
contentXML +=""+u.apmat+" ";
contentXML +=""+u.nombre+" ";
contentXML +=""+u.mail+" ";
contentXML +=""+u.cuenta_pagar+" ";
contentXML +=""+u.cuenta_cobrar+" ";
contentXML +=""+u.es_empleado+" ";
contentXML +=""+u.es_director+" ";
contentXML +=""+u.puesto+" ";
contentXML +=""+u.foto+" ";
contentXML +=""+u.estatus+" ";
contentXML +=""+u.passwd+" ";
contentXML +="";
contentXML +=""+a.usuario+" ";
contentXML +=""+a.passwd+" ";
contentXML +=" ";
contentXML +=" ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
try
{
URL url = new URL(uri);
connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
connection.setDoOutput(true);
connection.setRequestProperty("SOAPAction", "http://radt.expenses.services/services/CrearUsuario");
if (contentXML != null)
{
connection.setRequestProperty("Content-Length", Integer.toString(contentXML.length()));
Writer wr = new OutputStreamWriter(connection.getOutputStream(), StandardCharsets.UTF_8);
wr.write(contentXML);
wr.flush();
wr.close();
}
int responseCode = connection.getResponseCode();
if(responseCode == 200 || responseCode == 401 || responseCode == 409)
{
StringBuffer buffer = new StringBuffer();
BufferedReader reader;
if (responseCode == 200)
{
reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
}
else
reader = new BufferedReader(new InputStreamReader(connection.getErrorStream(), "UTF-8"));
String linea;
while((linea = reader.readLine()) != null)
{
buffer.append(linea);
}
response = buffer.toString();
} else if( responseCode == 400 )
{
throw new RuntimeException("Error 400: Bad Request");
} else
{
throw new RuntimeException("Error: ResponseCode = " + responseCode);
}
}
catch(Exception e)
{
response = null;
throw new RuntimeException( e.getMessage() );
}
return response;
}
public static void main(String[] args) {
usuario u = new usuario();
admin a = new admin();
String token="eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiwgImNvbm5lY3Rpb25faWQiOiJjbm5FeHBlbnNlc1NlbWlsbGFWMTAifQ==.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=";
u.i_clave="133";
u.empresa=" ";
u.jefe=" ";
u.centro_costo=" ";
u.grupo=" ";
u.usuario_acl=" ";
u.no_empleado=" ";
u.appat=" ";
u.apmat=" ";
u.nombre=" ";
u.mail=" ";
u.cuenta_pagar=" ";
u.cuenta_cobrar=" ";
u.es_empleado=" ";
u.es_director=" ";
u.puesto="Director creativo";
u.foto=" ";
u.estatus=" ";
u.passwd=" ";
a.usuario="PRAMIREZMN";
a.passwd="PRAMIREZMN";
actualizarUsuario(token, u, a);
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio de Actualizar Usuario
public class UpdateUsuario {
private static final String URLBase = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion";
public static void updateUsuario(String body) throws ClientProtocolException, IOException {
@SuppressWarnings("deprecation")
String petition = UpdateUsuario.URLBase + "/usuario";
HttpClient client = new DefaultHttpClient();
HttpPut request = new HttpPut(petition);
StringEntity params = new StringEntity(body);
request.setEntity(params);
request.setHeader("Content-Type", "application/json");
request.setHeader("token", "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiwgImNvbm5lY3Rpb25faWQiOiJjbm5FeHBlbnNlc1NlbWlsbGFWMTAifQ==.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=");
HttpResponse response = client.execute(request);
BufferedReader rd = new BufferedReader (new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
}
public static void main(String[] args) throws ClientProtocolException, IOException {
String body =
"{" +
"\"i_clave\":133," +
"\"empresa\":\"K010\"," +
"\"jefe\":null," +
"\"centro_costo\":null," +
"\"grupo\":null," +
"\"usuario_acl\":\"YTREJOPEMN45\"," +
"\"no_empleado\":null," +
"\"appat\":null," +
"\"apmat\":null," +
"\"nombre\":null," +
"\"passwd\":null," +
"\"mail\":null," +
"\"cuenta_pagar\":null," +
"\"cuenta_cobrar\":null," +
"\"es_empleado\":null," +
"\"es_director\":null," +
"\"puesto\":null," +
"\"foto\":null," +
"\"estatus\":null," +
"\"admin\":{" +
"\"usuario\":\"PRAMIREZMN\"," +
"\"passwd\":\"PRAMIREZMN\"" +
"}" +
"}";
UpdateUsuario.updateUsuario(body);
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio SOAP Crear Concepto
public class crearConcepto {
public static class concepto{
public String i_clave;
public String nombre;
public String codigo;
public String cuenta;
public String cfdi;
public String pdf;
public String archivo;
public String arch_extranjero;
public String propina;
public String estatus;
}
public static String crearConcepto(String token, concepto c)
{
String uri = "http://qa.core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios";
String contentXML = "";
String response = null;
HttpURLConnection connection = null;
contentXML += "";
contentXML += " ";
contentXML += "";
contentXML += "";
contentXML += "" + token + " ";
contentXML +="";
contentXML +=""+c.i_clave+" ";
contentXML +=""+c.nombre+" ";
contentXML +=""+c.codigo+" ";
contentXML +=""+c.cuenta+" ";
contentXML +=""+ c.cfdi +" ";
contentXML +=""+c.pdf+" ";
contentXML +=""+c.archivo+" ";
contentXML +=""+c.arch_extranjero+" ";
contentXML +=""+c.propina+" ";
contentXML +=""+c.estatus+" ";
contentXML +=" ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
try
{
URL url = new URL(uri);
connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
connection.setDoOutput(true);
connection.setRequestProperty("SOAPAction", "http://radt.expenses.services/services/CrearConcepto");
if (contentXML != null)
{
connection.setRequestProperty("Content-Length", Integer.toString(contentXML.length()));
Writer wr = new OutputStreamWriter(connection.getOutputStream(), StandardCharsets.UTF_8);
wr.write(contentXML);
wr.flush();
wr.close();
}
int responseCode = connection.getResponseCode();
if(responseCode == 200 || responseCode == 401 || responseCode == 409)
{
StringBuffer buffer = new StringBuffer();
BufferedReader reader;
if (responseCode == 200)
{
reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
}
else
reader = new BufferedReader(new InputStreamReader(connection.getErrorStream(), "UTF-8"));
String linea;
while((linea = reader.readLine()) != null)
{
buffer.append(linea);
}
response = buffer.toString();
} else if( responseCode == 400 )
{
throw new RuntimeException("Error 400: Bad Request");
} else
{
throw new RuntimeException("Error: ResponseCode = " + responseCode);
}
}
catch(Exception e)
{
response = null;
throw new RuntimeException( e.getMessage() );
}
return response;
}
public static void main(String[] args) {
concepto c = new concepto();
String token="eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiwgImNvbm5lY3Rpb25faWQiOiJjbm5FeHBlbnNlc1NlbWlsbGFWMTAifQ==.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=";
c.i_clave="";
c.nombre="Pasajes";
c.codigo="CPSH58";
c.cuenta="CC-01267849";
c.cfdi="S";
c.pdf="N";
c.archivo="N";
c.arch_extranjero="N";
c.propina="N";
c.estatus="";
crearConcepto(token, c);
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST Crear Concepto
public class CreateConcepto {
private static final String URLBase = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion";
public static void CreateConcepto(String body) throws ClientProtocolException, IOException {
@SuppressWarnings("deprecation")
String petition = CreateConcepto.URLBase + "/concepto";
HttpClient client = new DefaultHttpClient();
HttpPost request = new HttpPost(petition);
StringEntity params = new StringEntity(body);
request.setEntity(params);
request.setHeader("Accept", "application/json");
request.setHeader("Content-Type", "application/json");
request.setHeader("token", "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiwgImNvbm5lY3Rpb25faWQiOiJjbm5FeHBlbnNlc1NlbWlsbGFWMTAifQ==.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=");
HttpResponse response = client.execute(request);
BufferedReader rd = new BufferedReader (new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
}
public static void main(String[] args) throws ClientProtocolException, IOException {
String body =
"{" +
" \"i_clave\": null," +
" \"nombre\": \"Cosas de prueba 5\"," +
" \"codigo\": \"CPSH5\"," +
" \"cuenta\": \"CC-01267849\"," +
" \"cfdi\": \"S\"," +
" \"pdf\": \"N\"," +
" \"archivo\": \"N\"," +
" \"arch_extranjero\": \"N\"," +
" \"propina\": \"N\"," +
" \"estatus\": null" +
"}";
CreateConcepto.CreateConcepto(body);
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio SOAP Concepto
public static String concepto(String token,String id_concepto)
{
String uri = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios";
String contentXML = "";
String response = null;
HttpURLConnection connection = null;
contentXML += "";
contentXML += " ";
contentXML += "";
contentXML += "";
contentXML += "" + token + " ";
contentXML += "" + id_concepto + " ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
try
{
URL url = new URL(uri);
connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
connection.setDoOutput(true);
connection.setRequestProperty("SOAPAction", "http://radt.expenses.services/services/Concepto");
if (contentXML != null)
{
connection.setRequestProperty("Content-Length", Integer.toString(contentXML.length()));
Writer wr = new OutputStreamWriter(connection.getOutputStream(), StandardCharsets.UTF_8);
wr.write(contentXML);
wr.flush();
wr.close();
}
int responseCode = connection.getResponseCode();
if(responseCode == 200 || responseCode == 401 || responseCode == 409)
{
StringBuffer buffer = new StringBuffer();
BufferedReader reader;
if (responseCode == 200)
{
reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
}
else
reader = new BufferedReader(new InputStreamReader(connection.getErrorStream(), "UTF-8"));
String linea;
while((linea = reader.readLine()) != null)
{
buffer.append(linea);
}
response = buffer.toString();
} else if( responseCode == 400 )
{
throw new RuntimeException("Error 400: Bad Request");
} else
{
throw new RuntimeException("Error: ResponseCode = " + responseCode);
}
}
catch(Exception e)
{
response = null;
throw new RuntimeException( e.getMessage() );
}
return response;
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST Concepto
public class GetConcepto {
private static final String URLBase = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion";
public static void GetConcepto(String id) throws ClientProtocolException, IOException {
@SuppressWarnings("deprecation")
String petition = GetConcepto.URLBase + "/concepto/" + id;
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(petition);
request.setHeader("Content-Type", "application/json");
request.setHeader("token", "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiwgImNvbm5lY3Rpb25faWQiOiJjbm5FeHBlbnNlc1NlbWlsbGFWMTAifQ==.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=");
HttpResponse response = client.execute(request);
BufferedReader rd = new BufferedReader (new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
}
public static void main(String[] args) throws ClientProtocolException, IOException {
GetConcepto.GetConcepto("1");
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio SOAP Conceptos
public static String conceptos(String token)
{
String uri = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios";
String contentXML = "";
String response = null;
HttpURLConnection connection = null;
contentXML += "";
contentXML += " ";
contentXML += "";
contentXML += "";
contentXML += "" + token + " ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
try
{
URL url = new URL(uri);
connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
connection.setDoOutput(true);
connection.setRequestProperty("SOAPAction", "http://radt.expenses.services/services/Conceptos");
if (contentXML != null)
{
connection.setRequestProperty("Content-Length", Integer.toString(contentXML.length()));
Writer wr = new OutputStreamWriter(connection.getOutputStream(), StandardCharsets.UTF_8);
wr.write(contentXML);
wr.flush();
wr.close();
}
int responseCode = connection.getResponseCode();
if(responseCode == 200 || responseCode == 401 || responseCode == 409)
{
StringBuffer buffer = new StringBuffer();
BufferedReader reader;
if (responseCode == 200)
{
reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
}
else
reader = new BufferedReader(new InputStreamReader(connection.getErrorStream(), "UTF-8"));
String linea;
while((linea = reader.readLine()) != null)
{
buffer.append(linea);
}
response = buffer.toString();
} else if( responseCode == 400 )
{
throw new RuntimeException("Error 400: Bad Request");
} else
{
throw new RuntimeException("Error: ResponseCode = " + responseCode);
}
}
catch(Exception e)
{
response = null;
throw new RuntimeException( e.getMessage() );
}
return response;
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio de Conceptos
public class GetConceptos {
private static final String URLBase = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion";
public static void getConceptos() throws ClientProtocolException, IOException {
@SuppressWarnings("deprecation")
String petition = GetConceptos.URLBase + "/conceptos";
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(petition);
request.setHeader("Content-Type", "application/json");
request.setHeader("token", "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiwgImNvbm5lY3Rpb25faWQiOiJjbm5FeHBlbnNlc1NlbWlsbGFWMTAifQ==.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=");
HttpResponse response = client.execute(request);
BufferedReader rd = new BufferedReader (new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
}
public static void main(String[] args) throws ClientProtocolException, IOException {
GetConceptos.getConceptos();
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio SOAP Actualizar Conceptos
public class actualizarConcepto {
public static class concepto{
public String i_clave;
public String nombre;
public String codigo;
public String cuenta;
public String cfdi;
public String pdf;
public String archivo;
public String arch_extranjero;
public String propina;
public String estatus;
}
public static String actualizarConcepto(String token, concepto c)
{
String uri = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios";
String contentXML = "";
String response = null;
HttpURLConnection connection = null;
contentXML += "";
contentXML += " ";
contentXML += "";
contentXML += "";
contentXML += "" + token + " ";
contentXML +="";
contentXML +=""+c.i_clave+" ";
contentXML +=""+c.nombre+" ";
contentXML +=""+c.codigo+" ";
contentXML +=""+c.cuenta+" ";
contentXML +=""+ c.cfdi +" ";
contentXML +=""+c.pdf+" ";
contentXML +=""+c.archivo+" ";
contentXML +=""+c.arch_extranjero+" ";
contentXML +=""+c.propina+" ";
contentXML +=""+c.estatus+" ";
contentXML +=" ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
try
{
URL url = new URL(uri);
connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
connection.setDoOutput(true);
connection.setRequestProperty("SOAPAction", "http://radt.expenses.services/services/ActualizarConcepto");
if (contentXML != null)
{
connection.setRequestProperty("Content-Length", Integer.toString(contentXML.length()));
Writer wr = new OutputStreamWriter(connection.getOutputStream(), StandardCharsets.UTF_8);
wr.write(contentXML);
wr.flush();
wr.close();
}
int responseCode = connection.getResponseCode();
if(responseCode == 200 || responseCode == 401 || responseCode == 409)
{
StringBuffer buffer = new StringBuffer();
BufferedReader reader;
if (responseCode == 200)
{
reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
}
else
reader = new BufferedReader(new InputStreamReader(connection.getErrorStream(), "UTF-8"));
String linea;
while((linea = reader.readLine()) != null)
{
buffer.append(linea);
}
response = buffer.toString();
} else if( responseCode == 400 )
{
throw new RuntimeException("Error 400: Bad Request");
} else
{
throw new RuntimeException("Error: ResponseCode = " + responseCode);
}
}
catch(Exception e)
{
response = null;
throw new RuntimeException( e.getMessage() );
}
return response;
}
public static void main(String[] args) {
concepto c = new concepto();
String token="eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiwgImNvbm5lY3Rpb25faWQiOiJjbm5FeHBlbnNlc1NlbWlsbGFWMTAifQ==.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=";
c.i_clave="5";
c.nombre="Comidas por representacion";
c.codigo="";
c.cuenta="";
c.cfdi="";
c.pdf="";
c.archivo="";
c.arch_extranjero="";
c.propina="";
c.estatus="";
actualizarConcepto(token, c);
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST Actualizar Conceptos
public class UpdateConcepto {
private static final String URLBase = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion";
public static void updateConcepto(String body) throws ClientProtocolException, IOException {
@SuppressWarnings("deprecation")
String petition = UpdateConcepto.URLBase + "/concepto";
HttpClient client = new DefaultHttpClient();
HttpPut request = new HttpPut(petition);
StringEntity params = new StringEntity(body);
request.setEntity(params);
request.setHeader("Content-Type", "application/json");
request.setHeader("token", "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiwgImNvbm5lY3Rpb25faWQiOiJjbm5FeHBlbnNlc1NlbWlsbGFWMTAifQ==.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=");
HttpResponse response = client.execute(request);
BufferedReader rd = new BufferedReader (new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
}
public static void main(String[] args) throws ClientProtocolException, IOException {
String body =
"{" +
" \"i_clave\": 7," +
" \"nombre\": \"Cosas de prueba 6\"," +
" \"codigo\": \"CPSH6\"," +
" \"cuenta\": null," +
" \"cfdi\": null," +
" \"pdf\": null," +
" \"archivo\": null," +
" \"arch_extranjero\": \"S\"," +
" \"propina\": null," +
" \"estatus\": null" +
"}";
UpdateConcepto.updateConcepto(body);
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio SOAP Crear Centro de Costos
public class crearCentroCostos {
public static class ceco{
public String i_clave;
public String empresa;
public String divisa;
public String gerente;
public String nombre;
public String codigo;
public String estatus;
}
public static String crearCentroCostos(String token, ceco c)
{
String uri = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios";
String contentXML = "";
String response = null;
HttpURLConnection connection = null;
contentXML += "";
contentXML += " ";
contentXML += "";
contentXML += "";
contentXML += "" + token + " ";
contentXML +="";
contentXML +=""+c.i_clave+" ";
contentXML +=""+c.empresa+" ";
contentXML +=""+c.divisa+" ";
contentXML +=""+c.gerente+" ";
contentXML +=""+ c.nombre +" ";
contentXML +=""+c.codigo+" ";
contentXML +=""+c.estatus+" ";
contentXML +=" ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
try
{
URL url = new URL(uri);
connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
connection.setDoOutput(true);
connection.setRequestProperty("SOAPAction", "http://radt.expenses.services/services/CrearCentroCostos");
if (contentXML != null)
{
connection.setRequestProperty("Content-Length", Integer.toString(contentXML.length()));
Writer wr = new OutputStreamWriter(connection.getOutputStream(), StandardCharsets.UTF_8);
wr.write(contentXML);
wr.flush();
wr.close();
}
int responseCode = connection.getResponseCode();
if(responseCode == 200 || responseCode == 401 || responseCode == 409)
{
StringBuffer buffer = new StringBuffer();
BufferedReader reader;
if (responseCode == 200)
{
reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
}
else
reader = new BufferedReader(new InputStreamReader(connection.getErrorStream(), "UTF-8"));
String linea;
while((linea = reader.readLine()) != null)
{
buffer.append(linea);
}
response = buffer.toString();
} else if( responseCode == 400 )
{
throw new RuntimeException("Error 400: Bad Request");
} else
{
throw new RuntimeException("Error: ResponseCode = " + responseCode);
}
}
catch(Exception e)
{
response = null;
throw new RuntimeException( e.getMessage() );
}
return response;
}
public static void main(String[] args) {
ceco c = new ceco();
String token="eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiwgImNvbm5lY3Rpb25faWQiOiJjbm5FeHBlbnNlc1NlbWlsbGFWMTAifQ==.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=";
c.i_clave="";
c.empresa="K001";
c.divisa="USD";
c.gerente="802345";
c.nombre="Ventas";
c.codigo="K0010067";
c.estatus="";
crearCentroCostos(token, c);
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST Crear Centro de Costos
public class CreateCeCo {
private static final String URLBase = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion";
public static void createCeCo(String body) throws ClientProtocolException, IOException {
@SuppressWarnings("deprecation")
String petition = CreateCeCo.URLBase + "/centro-costos";
HttpClient client = new DefaultHttpClient();
HttpPost request = new HttpPost(petition);
StringEntity params = new StringEntity(body);
request.setEntity(params);
request.setHeader("Accept", "application/json");
request.setHeader("Content-Type", "application/json");
request.setHeader("token", "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiwgImNvbm5lY3Rpb25faWQiOiJjbm5FeHBlbnNlc1NlbWlsbGFWMTAifQ==.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=");
HttpResponse response = client.execute(request);
BufferedReader rd = new BufferedReader (new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
}
public static void main(String[] args) throws ClientProtocolException, IOException {
String body =
"{" +
"\"i_clave\": null," +
"\"empresa\": \"K001\"," +
"\"divisa\": \"USD\"," +
"\"gerente\": \"802345\"," +
"\"nombre\": \"Ejemplo 2\"," +
"\"codigo\": \"K0010062\"," +
"\"estatus\": null" +
"}";
CreateCeCo.createCeCo(body);
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio SOAP Centro de Costos
public static String centroCostos(String token,String id_centro_costos)
{
String uri = "http://qa.core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios";
String contentXML = "";
String response = null;
HttpURLConnection connection = null;
contentXML += "";
contentXML += " ";
contentXML += "";
contentXML += "";
contentXML += "" + token + " ";
contentXML += "" + id_centro_costos + " ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
try
{
URL url = new URL(uri);
connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
connection.setDoOutput(true);
connection.setRequestProperty("SOAPAction", "http://radt.expenses.services/services/CentroCostos");
if (contentXML != null)
{
connection.setRequestProperty("Content-Length", Integer.toString(contentXML.length()));
Writer wr = new OutputStreamWriter(connection.getOutputStream(), StandardCharsets.UTF_8);
wr.write(contentXML);
wr.flush();
wr.close();
}
int responseCode = connection.getResponseCode();
if(responseCode == 200 || responseCode == 401 || responseCode == 409)
{
StringBuffer buffer = new StringBuffer();
BufferedReader reader;
if (responseCode == 200)
{
reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
}
else
reader = new BufferedReader(new InputStreamReader(connection.getErrorStream(), "UTF-8"));
String linea;
while((linea = reader.readLine()) != null)
{
buffer.append(linea);
}
response = buffer.toString();
} else if( responseCode == 400 )
{
throw new RuntimeException("Error 400: Bad Request");
} else
{
throw new RuntimeException("Error: ResponseCode = " + responseCode);
}
}
catch(Exception e)
{
response = null;
throw new RuntimeException( e.getMessage() );
}
return response;
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST Centro de Costos
public class GetCeCo {
private static final String URLBase = "http://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion";
public static void getCeCo(String id) throws ClientProtocolException, IOException {
@SuppressWarnings("deprecation")
String petition = GetCeCo.URLBase + "/centro-costos/" + id;
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(petition);
request.setHeader("Content-Type", "application/json");
request.setHeader("token", "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiwgImNvbm5lY3Rpb25faWQiOiJjbm5FeHBlbnNlc1NlbWlsbGFWMTAifQ==.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=");
HttpResponse response = client.execute(request);
BufferedReader rd = new BufferedReader (new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
}
public static void main(String[] args) throws ClientProtocolException, IOException {
GetCeCo.getCeCo("18");
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio SOAP Centros de Costos
public static String centrosCostos(String token)
{
String uri = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios";
String contentXML = "";
String response = null;
HttpURLConnection connection = null;
contentXML += "";
contentXML += " ";
contentXML += "";
contentXML += "";
contentXML += "" + token + " ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
try
{
URL url = new URL(uri);
connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
connection.setDoOutput(true);
connection.setRequestProperty("SOAPAction", "http://radt.expenses.services/services/CentrosCostos");
if (contentXML != null)
{
connection.setRequestProperty("Content-Length", Integer.toString(contentXML.length()));
Writer wr = new OutputStreamWriter(connection.getOutputStream(), StandardCharsets.UTF_8);
wr.write(contentXML);
wr.flush();
wr.close();
}
int responseCode = connection.getResponseCode();
if(responseCode == 200 || responseCode == 401 || responseCode == 409)
{
StringBuffer buffer = new StringBuffer();
BufferedReader reader;
if (responseCode == 200)
{
reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
}
else
reader = new BufferedReader(new InputStreamReader(connection.getErrorStream(), "UTF-8"));
String linea;
while((linea = reader.readLine()) != null)
{
buffer.append(linea);
}
response = buffer.toString();
} else if( responseCode == 400 )
{
throw new RuntimeException("Error 400: Bad Request");
} else
{
throw new RuntimeException("Error: ResponseCode = " + responseCode);
}
}
catch(Exception e)
{
response = null;
throw new RuntimeException( e.getMessage() );
}
return response;
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST Centros de Costos
public class GetCeCos {
private static final String URLBase = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion";
public static void getCeCos() throws ClientProtocolException, IOException {
@SuppressWarnings("deprecation")
String petition = GetCeCos.URLBase + "/centros-costos";
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(petition);
request.setHeader("Content-Type", "application/json");
request.setHeader("token", "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiwgImNvbm5lY3Rpb25faWQiOiJjbm5FeHBlbnNlc1NlbWlsbGFWMTAifQ==.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=");
HttpResponse response = client.execute(request);
BufferedReader rd = new BufferedReader (new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
}
public static void main(String[] args) throws ClientProtocolException, IOException {
GetCeCos.getCeCos();
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio de Actualizar SOAP Centros de Costos
public class actualizarCentroCostos {
public static class ceco{
public String i_clave;
public String empresa;
public String divisa;
public String gerente;
public String nombre;
public String codigo;
public String estatus;
}
public static String actualizarCentroCostos(String token, ceco c)
{
String uri = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10-soap/servicios";
String contentXML = "";
String response = null;
HttpURLConnection connection = null;
contentXML += "";
contentXML += " ";
contentXML += "";
contentXML += "";
contentXML += "" + token + " ";
contentXML +="";
contentXML +=""+c.i_clave+" ";
contentXML +=""+c.empresa+" ";
contentXML +=""+c.divisa+" ";
contentXML +=""+c.gerente+" ";
contentXML +=""+ c.nombre +" ";
contentXML +=""+c.codigo+" ";
contentXML +=""+c.estatus+" ";
contentXML +=" ";
contentXML += " ";
contentXML += " ";
contentXML += " ";
try
{
URL url = new URL(uri);
connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
connection.setDoOutput(true);
connection.setRequestProperty("SOAPAction", "http://radt.expenses.services/services/ActualizarCentroCostos");
if (contentXML != null)
{
connection.setRequestProperty("Content-Length", Integer.toString(contentXML.length()));
Writer wr = new OutputStreamWriter(connection.getOutputStream(), StandardCharsets.UTF_8);
wr.write(contentXML);
wr.flush();
wr.close();
}
int responseCode = connection.getResponseCode();
if(responseCode == 200 || responseCode == 401 || responseCode == 409)
{
StringBuffer buffer = new StringBuffer();
BufferedReader reader;
if (responseCode == 200)
{
reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
}
else
reader = new BufferedReader(new InputStreamReader(connection.getErrorStream(), "UTF-8"));
String linea;
while((linea = reader.readLine()) != null)
{
buffer.append(linea);
}
response = buffer.toString();
} else if( responseCode == 400 )
{
throw new RuntimeException("Error 400: Bad Request");
} else
{
throw new RuntimeException("Error: ResponseCode = " + responseCode);
}
}
catch(Exception e)
{
response = null;
throw new RuntimeException( e.getMessage() );
}
return response;
}
public static void main(String[] args) {
ceco c = new ceco();
String token="eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiwgImNvbm5lY3Rpb25faWQiOiJjbm5FeHBlbnNlc1NlbWlsbGFWMTAifQ==.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=";
c.i_clave="21";
c.empresa="";
c.divisa="";
c.gerente="";
c.nombre="Comercial";
c.codigo="";
c.estatus="";
actualizarCentroCostos(token, c);
}
}
La siguiente función describe la invocación de e-Xpenses para solicitar el servicio REST Actualizar Centros de Costos
public class UpdateCeCo {
private static final String URLBase = "https://core.masnegocio.com/mn-e-xpenses-integracion-v10/integracion";
public static void updateCeCo(String body) throws ClientProtocolException, IOException {
@SuppressWarnings("deprecation")
String petition = UpdateCeCo.URLBase + "/centro-costos";
HttpClient client = new DefaultHttpClient();
HttpPut request = new HttpPut(petition);
StringEntity params = new StringEntity(body);
request.setEntity(params);
request.setHeader("Content-Type", "application/json");
request.setHeader("token", "eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0=.eyAic3ViIiA6ICJQQUNNTl9BUEkiLCAiaWF0IiA6ICIyMDE1MDIyMzA5MDAwMCIsICJrZXkiIDogInhNN3pjQ3kyTDg3RVpBQzNNcEhTVUhwMGtWOThBWGxoS0IyMjI4QUkwMDA9IiwgImNvbm5lY3Rpb25faWQiOiJjbm5FeHBlbnNlc1NlbWlsbGFWMTAifQ==.9AfJIOslGUKc6OtTbcuZNGITp3AgwznSPBqLsCXa9wk=");
HttpResponse response = client.execute(request);
BufferedReader rd = new BufferedReader (new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
}
public static void main(String[] args) throws ClientProtocolException, IOException {
String body =
"{" +
"\"i_clave\": 18," +
"\"empresa\": \"K010\"," +
"\"divisa\": \"MXN\"," +
"\"gerente\": null," +
"\"nombre\": null," +
"\"codigo\": null," +
"\"estatus\": null" +
"}";
UpdateCeCo.updateCeCo(body);
}
}