public void Out(string value) { //set the value of a output header SoapHeaderHelper <Header> .SetOutputHeader("MyHeader", new Header() { Value = value }); }
public string In() { //Use the value from a input header Header soapHeader = SoapHeaderHelper <Header> .GetInputHeader("MyHeader"); if (soapHeader != null) { return(soapHeader.Value); } return(null); }
public void InOut() { //Use input header Header soapHeader = SoapHeaderHelper <Header> .GetInputHeader("MyHeader"); if (soapHeader != null) { //and set the value back in the output header soapHeader.Value += " InOut"; SoapHeaderHelper <Header> .SetOutputHeader("MyHeader", soapHeader); } }
public bool DoWork() { AuthHeader authentication = SoapHeaderHelper <AuthHeader> .GetInputHeader("AuthHeader"); if (@"userName".Equals(authentication.Username) && @"pwd".Equals(authentication.Password)) { //Do your thing return(true); } else { //if authentication fails return(false); } }
/// <summary> /// Zápis do logu aplikace (v případě xml se xml deklarace a root element se zapisují zvlášť) /// </summary> /// <param name="type">Typ zprávy</param> /// <param name="message">Textová zpráva</param> /// <param name="xmlDeclaration">Hodnota xml deklarace</param> /// <param name="xmlMessage">Zpráva ve formátu xml</param> /// <param name="zicyzUserId">Id uživatele, zapisuje se do logu spolu s výsledkem operace</param> /// <param name="source">Zdroj relevantní k logované zprávě</param> /// <returns>Vrací instanci třídy <see cref="ProcResult"/> popisující výsledek operace</returns> public ProcResult AppLogWriteNew(string type, string message, string xmlDeclaration, string xmlMessage, int zicyzUserId, string source) { ProcResult result = new ProcResult(); result.ReturnValue = Bc.NotOk; if (this.VerifyToken() == false) { return(result); } using (var db = new FenixEntities()) { try { db.Configuration.LazyLoadingEnabled = false; db.Configuration.ProxyCreationEnabled = false; ObjectParameter retVal = new ObjectParameter("ReturnValue", typeof(int)); ObjectParameter retMsg = new ObjectParameter("ReturnMessage", typeof(string)); db.prAppLogWriteNew(type, message, xmlDeclaration, xmlMessage, zicyzUserId, source, retVal, retMsg); result.ReturnValue = retVal.Value.ToInt32(Bc.NotOk); result.ReturnMessage = retMsg.Value.ToString(String.Empty); SoapHeaderHelper <ActionResult> .SetOutputHeader("ActionResult", new ActionResult() { StatusId = ActionStatus.Success.ToShort(), StatusDesc = "OK" }); } catch (Exception ex) { result = Bc.CreateErrorResult(ApplicationLog.GetMethodName(), ex); SoapHeaderHelper <ActionResult> .SetOutputHeader("ActionResult", new ActionResult() { StatusId = ActionStatus.Failure.ToShort(), StatusDesc = ex.Message }); } } return(result); }
public System.Data.DataSet Read(string targetCategory, string viewName, NBK.Common.Foundations.Utilities.FilterCriteria[] filterCriteria, NBK.Common.Foundations.Utilities.SortCriteria[] sortCriteria, int startIndex, int numberOfRecords, ref int totalNumberOfRecords) { try { Header = SoapHeaderHelper <WebServiceHeader> .GetInputHeader("Header"); const string location = "NBK.EAI.Services.Web.NBKCentral.Read"; using (LogEnterExit lee = new LogEnterExit(location)) { string _instanceName = ""; if (string.IsNullOrEmpty(viewName)) { _instanceName = "READ_" + targetCategory + "_VW_" + "Default"; } else { _instanceName = "READ_" + targetCategory + "_VW_" + viewName; } //Do data validation before delegating to Request Router CheckArgument(targetCategory != null && targetCategory != "", "Target Category cannot be null or empty"); //Delegate the call to the Request Router class DataSet result = RequestRouter.Read(GetCallContext(), targetCategory, viewName, filterCriteria, sortCriteria, startIndex, numberOfRecords, ref totalNumberOfRecords); return(result); } } catch (Exception ex) { BaseException.Publish(ex); //LogCallContext(); throw ExceptionUtils.GetSOAPException(ex); } }
/// <summary> /// Ověření tokenu /// </summary> /// <returns></returns> private bool VerifyToken() { this._appId = String.Empty; // Získání tokenu z hlavičky AuthToken authToken = SoapHeaderHelper <AuthToken> .GetInputHeader("AuthToken"); string token = (authToken == null ? String.Empty : authToken.Value); if (String.IsNullOrWhiteSpace(token)) { SoapHeaderHelper <ActionResult> .SetOutputHeader("ActionResult", new ActionResult() { StatusId = ActionStatus.InvalidToken.ToShort(), StatusDesc = "Invalid token" }); return(false);; } // Ověření platnosti tokenu Token tkn = new Token(Bc.SecretKey, "AuthToken", token); TokenStatus stat = tkn.Verify(); this._appId = tkn.Id; if (stat != TokenStatus.Valid) { SoapHeaderHelper <ActionResult> .SetOutputHeader("ActionResult", new ActionResult() { StatusId = ActionStatus.InvalidToken.ToShort(), StatusDesc = "Invalid token" }); return(false);; } return(true); }
/// <summary> /// Vlastní zpracování daného typu procesu (ReceptionConfirmation, KittingConfirmation ...) /// </summary> /// <param name="processType"></param> /// <param name="xmlMessage">Zpráva ve formátu xml</param> /// <param name="zicyzUserId">Id uživatele, zapisuje se do logu spolu s výsledkem operace</param> /// <returns></returns> private ProcResult DoConfirmationProcess(ProcessType processType, string xmlMessage, int zicyzUserId) { ProcResult result = new ProcResult(); result.ReturnValue = Bc.NotOk; if (this.VerifyToken() == false) { return(result); } using (var db = new FenixEntities()) { try { db.Configuration.LazyLoadingEnabled = false; db.Configuration.ProxyCreationEnabled = false; db.Database.CommandTimeout = Bc.DbCommandTimeout; var par1Parameter = new SqlParameter(); par1Parameter.ParameterName = "@par1"; par1Parameter.Value = xmlMessage; par1Parameter.Direction = System.Data.ParameterDirection.Input; par1Parameter.SqlDbType = System.Data.SqlDbType.NVarChar; par1Parameter.Size = int.MaxValue - 1; var returnValue = new SqlParameter(); returnValue.ParameterName = "@ReturnValue"; returnValue.Direction = System.Data.ParameterDirection.InputOutput; returnValue.SqlDbType = System.Data.SqlDbType.Int; returnValue.Value = 0; var returnMessage = new SqlParameter(); returnMessage.ParameterName = "@ReturnMessage"; returnMessage.Direction = System.Data.ParameterDirection.InputOutput; returnMessage.SqlDbType = System.Data.SqlDbType.NVarChar; returnMessage.Size = 2048; returnMessage.Value = ""; // diky problémům v EF 6 (rollback ve SP) je nutno SP volat tímto způsobem var res = db.Database.ExecuteSqlCommand(TransactionalBehavior.DoNotEnsureTransaction, this.createSqlCommand(processType), par1Parameter, returnValue, returnMessage); result.ReturnValue = returnValue.Value.ToInt32(Bc.NotOk); result.ReturnMessage = returnMessage.Value.ToString(String.Empty); SoapHeaderHelper <ActionResult> .SetOutputHeader("ActionResult", new ActionResult() { StatusId = ActionStatus.Success.ToShort(), StatusDesc = "OK" }); } catch (Exception ex) { result = Bc.CreateErrorResult(ApplicationLog.GetMethodName(), ex); SoapHeaderHelper <ActionResult> .SetOutputHeader("ActionResult", new ActionResult() { StatusId = ActionStatus.Failure.ToShort(), StatusDesc = ex.Message }); } } logResult(result, ApplicationLog.GetMethodName(), zicyzUserId); return(result); }