/// <summary> /// Adaptor function (action with no return value) for invoking the Web Service layer /// </summary> /// <typeparam name="IWebService"></typeparam> /// <typeparam name="TResult"></typeparam> /// <param name="wsCallExpression"></param> protected void InvokeWebService <TWebService, TChannel, TResult>(Expression <Action <TChannel> > wsCallExpression, Action <Exception> exceptionHandler = null, bool isNtmlCreditalRequire = false) where TWebService : ClientBase <TChannel>, TChannel, new() where TChannel : class { try { var tClient = CreateServiceInstance <TWebService, TChannel>(isNtmlCreditalRequire); wsCallExpression.Compile().Invoke(tClient); } catch (Exception ex) { if (exceptionHandler != null) { exceptionHandler.Invoke(ex); } else { var msg = string.Format("Exception in Service Gateway -> {0} -> {1}: {2}", typeof(TChannel).ToString(), wsCallExpression.ToString(), ex.Message); LoggingSvc.Log(new Exception(msg, ex), category: Category.Web); throw; } } }
protected TResult InvokeWebService <TWebService, TChannel, TResult>(Expression <Func <TChannel, TResult> > wsCallExpression, Action <Exception> exceptionHandler = null, bool isNtmlCreditalRequire = false) where TWebService : ClientBase <TChannel>, TChannel, new() where TChannel : class { TResult result = default(TResult); try { var tClient = CreateServiceInstance <TWebService, TChannel>(isNtmlCreditalRequire); // SP: Comment Service Gateway performance diagnostics since we are using TPL //var timer = new System.Diagnostics.Stopwatch(); //timer.Start(); result = wsCallExpression.Compile().Invoke(tClient); ////timer.Stop(); //var msg = string.Format("PerformanceDiagnostics | {0} | {1} | {2}", "Service Invocation", wsCallExpression.ToString(), timer.ElapsedMilliseconds); //LoggingSvc.Log(msg, category: Category.BPM, severity: System.Diagnostics.TraceEventType.Verbose); } catch (Exception ex) { if (exceptionHandler != null) { exceptionHandler.Invoke(ex); } else { var msg = string.Format("Exception in Service Gateway -> {0} -> {1}: {2}", typeof(TChannel).ToString(), wsCallExpression.ToString(), ex.Message); LoggingSvc.Log(new Exception(msg, ex), category: Category.Web); throw; } } return(result); }