/// <summary> /// Ejecuta un servicio de negocio. /// </summary> /// <param name="providerName">Nombre del proveedor de metadata de servicios.-</param> /// <param name="serviceName">Nombre del servicio de negocio.</param> /// <param name="pXmlRequest">XML con datos de entrada para la ejecución del servicio.</param> /// <returns>XML con el resultado de la ejecución del servicio.</returns> /// <date>2008-04-07T00:00:00</date> /// <author>moviedo</author> public static string ExecuteService(string providerName, string serviceName, string pXmlRequest) { string wResult; ServiceConfiguration wServiceConfiguration = FacadeHelper.GetServiceConfiguration(providerName, serviceName); IServiceContract wRequest = (IServiceContract)ReflectionFunctions.CreateInstance(wServiceConfiguration.Request); if (wRequest == null) { TechnicalException te = new TechnicalException(string.Concat("El despachador de servicio no pudo continuar debido\r\na que no logro construir el requets del servicio: ", serviceName, "\r\nVerifique que se encuentre los componentes necesarios para su ejecucion esten en el servidor de aplicación. ")); Fwk.Exceptions.ExceptionHelper.SetTechnicalException <StaticFacade>(te); if (string.IsNullOrEmpty(ConfigurationsHelper.HostApplicationName)) { te.Source = "Despachador de servicios en " + Environment.MachineName; } else { te.Source = ConfigurationsHelper.HostApplicationName; } te.ErrorId = "7003"; throw te; } wRequest.SetXml(pXmlRequest); wResult = ExecuteService(providerName, wRequest).GetXml(); return(wResult); }
/// <summary> /// Ejecuta un servicio de negocio. /// </summary> /// <param name="providerName">Nombre del proveedor de metadata de servicios.-</param> /// <param name="serviceName">Nombre del servicio de negocio.</param> /// <param name="jsonRequest">JSON con datos de entrada para la ejecución del servicio.</param> /// <param name="hostContext">Info del despachador de servicio</param> /// <returns>JSON con el resultado de la ejecución del servicio.</returns> /// <date>2008-04-07T00:00:00</date> /// <author>moviedo</author> public string ExecuteServiceJson(string providerName, string serviceName, string jsonRequest, HostContext hostContext) { string wResult; if (string.IsNullOrEmpty(serviceName)) { throw get_TechnicalException_error_serviceName_null(); } ServiceConfiguration serviceConfiguration = FacadeHelper.GetServiceConfiguration(providerName, serviceName); Type reqType = Try_get_reqType(providerName, serviceConfiguration); var wRequest = (IServiceContract)Fwk.HelperFunctions.SerializationFunctions.DeSerializeObjectFromJson(reqType, jsonRequest); wRequest.ContextInformation.HostName = hostContext.HostName; wRequest.ContextInformation.HostIp = hostContext.HostIp; IServiceContract res = ExecuteService(providerName, (IServiceContract)wRequest); Type resType = Type.GetType(serviceConfiguration.Response); if (resType == null) { throw new TechnicalException(string.Concat("El servicio ", serviceName, " no se encuentra configurado verifique el Response: ", serviceConfiguration.Response)); } wResult = Fwk.HelperFunctions.SerializationFunctions.SerializeObjectToJson(resType, res); return(wResult); }
/// <summary> /// Ejecuta un servicio de negocio. /// </summary> /// <param name="providerName">Nombre del proveedor de metadata de servicios.-</param> /// <param name="pRequest">Request con datos de entrada para la ejecución del servicio.</param> /// <returns>XML con el resultado de la ejecución del servicio.</returns> /// <date>2008-04-07T00:00:00</date> /// <author>moviedo</author> public IServiceContract ExecuteService(string providerName, IServiceContract pRequest) { IServiceContract wResult = null; if (string.IsNullOrEmpty(pRequest.ServiceName)) { throw get_TechnicalException_error_serviceName_null(); } Boolean wExecuteOndispatcher = true; IRequest req = (IRequest)pRequest; ServiceConfiguration wServiceConfiguration = FacadeHelper.GetServiceConfiguration(providerName, pRequest.ServiceName); //establezco el nombre del proveedor de seguridad al request req.SecurityProviderName = FacadeHelper.GetProviderInfo(providerName).SecurityProviderName; req.ContextInformation.SetProviderName(providerName); //if (String.IsNullOrEmpty(req.ContextInformation.DefaultCulture)) // req.ContextInformation.DefaultCulture = FacadeHelper.GetProviderInfo(providerName).DefaultCulture; // Validación de disponibilidad del servicio. FacadeHelper.ValidateAvailability(wServiceConfiguration, out wResult); if (wResult != null) { if (wResult.Error != null) { return(wResult); } } // Caching del servicio. if (req.CacheSettings != null && req.CacheSettings.CacheOnServerSide) //--------->>> Implement the cache factory { wResult = GetCaheDataById(req, wServiceConfiguration); if (wResult != null) { wExecuteOndispatcher = false; } } // Realiza la ejecucion del servicio if (wExecuteOndispatcher) { // ejecución del servicio. if (wServiceConfiguration.TransactionalBehaviour == Fwk.Transaction.TransactionalBehaviour.Suppres) { wResult = FacadeHelper.RunNonTransactionalProcess(pRequest, wServiceConfiguration); } else { wResult = FacadeHelper.RunTransactionalProcess(pRequest, wServiceConfiguration); } } return(wResult); }
/// <summary> /// Ejecuta un servicio de negocio. /// </summary> /// <param name="providerName">Nombre del proveedor de metadata de servicios.-</param> /// <param name="serviceName">Nombre del servicio de negocio.</param> /// <param name="pXmlRequest">XML con datos de entrada para la ejecución del servicio.</param> /// <returns>XML con el resultado de la ejecución del servicio.</returns> /// <date>2008-04-07T00:00:00</date> /// <author>moviedo</author> public string ExecuteService(string providerName, string serviceName, string pXmlRequest) { string wResult; if (string.IsNullOrEmpty(serviceName)) { throw get_TechnicalException_error_serviceName_null(); } ServiceConfiguration serviceConfiguration = FacadeHelper.GetServiceConfiguration(providerName, serviceName); IServiceContract wRequest = Try_get_IServiceContract(providerName, serviceConfiguration); wRequest.SetXml(pXmlRequest); wResult = ExecuteService(providerName, wRequest).GetXml(); return(wResult); }
/// <summary> /// Ejecuta un servicio de negocio. /// </summary> /// <param name="providerName">Nombre del proveedor de metadata de servicios.-</param> /// <param name="serviceName">Nombre del servicio de negocio.</param> /// <param name="jsonRequest">JSON con datos de entrada para la ejecución del servicio.</param> /// <param name="hostContext">Info del despachador de servicio</param> /// <returns>JSON con el resultado de la ejecución del servicio.</returns> /// <date>2008-04-07T00:00:00</date> /// <author>moviedo</author> public static string ExecuteServiceJson(string providerName, string serviceName, string jsonRequest, HostContext hostContext) { string wResult; ServiceConfiguration wServiceConfiguration = FacadeHelper.GetServiceConfiguration(providerName, serviceName); Type reqType = ReflectionFunctions.CreateType(wServiceConfiguration.Request); if (reqType == null) { TechnicalException te = new TechnicalException(string.Concat("El despachador de servicio no pudo continuar debido\r\na que no logro construir el requets del servicio: ", serviceName, "\r\nVerifique que se encuentre los componentes necesarios para su ejecucion esten en el servidor de aplicación. ")); Fwk.Exceptions.ExceptionHelper.SetTechnicalException <StaticFacade>(te); if (string.IsNullOrEmpty(ConfigurationsHelper.HostApplicationName)) { te.Source = "Despachador de servicios en " + Environment.MachineName; } else { te.Source = ConfigurationsHelper.HostApplicationName; } te.ErrorId = "7003"; throw te; } var wRequest = (IServiceContract)Fwk.HelperFunctions.SerializationFunctions.DeSerializeObjectFromJson(reqType, jsonRequest); wRequest.ContextInformation.HostName = hostContext.HostName; wRequest.ContextInformation.HostIp = hostContext.HostIp; IServiceContract res = ExecuteService(providerName, (IServiceContract)wRequest); Type resType = Type.GetType(wServiceConfiguration.Response); wResult = Fwk.HelperFunctions.SerializationFunctions.SerializeObjectToJson(resType, res); return(wResult); }
/// <summary> /// Obtiene la configuracion de un servicio /// </summary> /// <param name="providerName">Nombre del proveedor de la metadata de szervicio</param> /// <param name="serviceName">Nombre del servicio a obtener</param> /// <returns>Informacion del servicio</returns> public static String GetServiceConfiguration(String providerName, String serviceName) { ServiceConfiguration wServiceConfiguration = null; String wServiceInfo; try { wServiceConfiguration = FacadeHelper.GetServiceConfiguration(providerName, serviceName); wServiceInfo = wServiceConfiguration.GetXml(); } catch (System.NullReferenceException) { throw new TechnicalException(string.Concat("El servicio ", serviceName, " no se encuentra configurado")); } catch (Exception e) { //TODO: Poner Id error //wServiceInfo = Fwk.Exceptions.ExceptionHelper.GetAllMessageException(e); throw new TechnicalException(string.Concat("Error al obtener la configuracion del servicio servicio ", serviceName), e); } return(wServiceInfo); }
/// <summary> /// Ejecuta un servicio de negocio. /// </summary> /// <param name="providerName">Nombre del proveedor de metadata de servicios.-</param> /// <param name="pRequest">Request con datos de entrada para la ejecución del servicio.</param> /// <returns>XML con el resultado de la ejecución del servicio.</returns> /// <date>2008-04-07T00:00:00</date> /// <author>moviedo</author> public static IServiceContract ExecuteService(string providerName, IServiceContract pRequest) { IServiceContract wResult = null; if (string.IsNullOrEmpty(pRequest.ServiceName)) { TechnicalException te = new TechnicalException("El despachador de servicio no pudo continuar debido\r\n a que el nombre del servicio no fue establecido"); Fwk.Exceptions.ExceptionHelper.SetTechnicalException <SimpleFacade>(te); te.ErrorId = "7005"; throw te; } Boolean wExecuteOndispatcher = true; IRequest req = (IRequest)pRequest; ServiceConfiguration wServiceConfiguration = FacadeHelper.GetServiceConfiguration(providerName, pRequest.ServiceName); //establezco el nombre del proveedor de seguridad al request req.SecurityProviderName = FacadeHelper.GetProviderInfo(providerName).SecurityProviderName; req.ContextInformation.SetProviderName(providerName); // Validación de disponibilidad del servicio. FacadeHelper.ValidateAvailability(wServiceConfiguration, out wResult); if (wResult != null) { if (wResult.Error != null) { return(wResult); } } // Caching del servicio. if (req.CacheSettings != null && req.CacheSettings.CacheOnServerSide) //--------->>> Implement the cache factory { wResult = GetCaheDataById(req, wServiceConfiguration); if (wResult != null) { wExecuteOndispatcher = false; } } // Realiza la ejecucion del servicio if (wExecuteOndispatcher) { // ejecución del servicio. if (wServiceConfiguration.TransactionalBehaviour == Fwk.Transaction.TransactionalBehaviour.Suppres) { wResult = FacadeHelper.RunNonTransactionalProcess(pRequest, wServiceConfiguration); } else { wResult = FacadeHelper.RunTransactionalProcess(pRequest, wServiceConfiguration); } } return(wResult); }