/// <summary> /// /// </summary> /// <param name="providerName"></param> /// <param name="serviceName"></param> /// <param name="jsonRequets"></param> /// <returns></returns> string IFwkService.ExecuteService(String providerName, String serviceName, String jsonRequets) { string[] computer_name = null; HostContext hostContext = new HostContext(); OperationContext context = OperationContext.Current; MessageProperties prop = context.IncomingMessageProperties; RemoteEndpointMessageProperty endpoint = prop[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty; computer_name = Dns.GetHostEntry(endpoint.Address).HostName.Split(new Char[] { '.' }); hostContext.HostIp = endpoint.Address; if (computer_name.Count() > 0) hostContext.HostName = computer_name[0].ToString(); return wSimpleFacade.ExecuteServiceJson(providerName, serviceName, jsonRequets, hostContext); }
void CreateSimpleFacade() { if (simpleFacade == null) { simpleFacade = new Fwk.BusinessFacades.SimpleFacade(); } if (hostContext == null) { string[] computer_name = null; hostContext = new HostContext(); OperationContext context = OperationContext.Current; MessageProperties prop = context.IncomingMessageProperties; RemoteEndpointMessageProperty endpoint = prop[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty; computer_name = Dns.GetHostEntry(endpoint.Address).HostName.Split(new Char[] { '.' }); hostContext.HostIp = endpoint.Address; if (computer_name.Count() > 0) hostContext.HostName = computer_name[0].ToString(); } }
/// <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 = Type.GetType(wServiceConfiguration.Request); if (reqType == null) { TechnicalException te = new TechnicalException(string.Concat("El despachador de servicio no pudo continuar debido\r\na que no 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; }