protected MakeConnectionMessageFault(Message message, FaultCode code, string subcode, FaultReason reason)
 {
     this.code              = code;
     this.subcode           = subcode;
     this.reason            = reason;
     this.isRemote          = true;
     this.originalMessageId = message.Headers.MessageId;
 }
Exemplo n.º 2
0
 // remote
 protected WsrmHeaderFault(FaultCode code, string subcode, FaultReason reason, bool faultsInput,
                           bool faultsOutput)
     : base(code, subcode, reason)
 {
     this.subcode      = subcode;
     this.faultsInput  = faultsInput;
     this.faultsOutput = faultsOutput;
 }
Exemplo n.º 3
0
 public SimpleMessageFault(FaultCode code,
                           FaultReason reason, bool has_detail,
                           object detail, XmlObjectSerializer formatter,
                           string actor, string node)
     : this(code, reason, detail, formatter, actor, node)
 {
     this.has_detail = has_detail;
 }
 public static MessageFault CreateFault(FaultCode code, FaultReason reason, object detail, XmlObjectSerializer serializer, string actor)
 {
     if (serializer == null)
     {
         throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("serializer"));
     }
     return(CreateFault(code, reason, detail, serializer, actor, actor));
 }
        internal static FaultException CreateAccessDeniedFaultException()
        {
            SecurityVersion wss         = SecurityVersion.WSSecurity11;
            FaultCode       faultCode   = FaultCode.CreateSenderFaultCode("FailedAuthentication", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
            FaultReason     faultReason = new FaultReason(new FaultReasonText("Access is denied", CultureInfo.CurrentCulture));

            return(new FaultException(faultReason, faultCode));
        }
Exemplo n.º 6
0
        internal static Exception CreateFailedAuthenticationFaultException()
        {
            SecurityVersion wss         = SecurityVersion.Default;
            FaultCode       faultCode   = FaultCode.CreateSenderFaultCode(wss.InvalidSecurityFaultCode.Value, wss.HeaderNamespace.Value);
            FaultReason     faultReason = new FaultReason(SR.AuthenticationOfClientFailed);

            return(new FaultException(faultReason, faultCode));
        }
Exemplo n.º 7
0
        internal static Exception CreateAccessDeniedFaultException()
        {
            SecurityVersion wss         = SecurityVersion.Default;
            FaultCode       faultCode   = FaultCode.CreateSenderFaultCode(wss.FailedAuthenticationFaultCode.Value, wss.HeaderNamespace.Value);
            FaultReason     faultReason = new FaultReason(SR.AccessDenied, CultureInfo.CurrentCulture);

            return(new FaultException(faultReason, faultCode));
        }
Exemplo n.º 8
0
            public Task <object> InvokeAsync(object instance, object[] inputs, out object[] outputs)
            {
                outputs = EmptyArray <object> .Allocate(0);

                Message message = inputs[0] as Message;

                if (message == null)
                {
                    return(null);
                }

                string action = message.Headers.Action;

                FaultCode code = FaultCode.CreateSenderFaultCode(AddressingStrings.ActionNotSupported,
                                                                 message.Version.Addressing.Namespace);
                string      reasonText = SR.Format(SR.SFxNoEndpointMatchingContract, action);
                FaultReason reason     = new FaultReason(reasonText);

                FaultException exception = new FaultException(reason, code);

                ErrorBehavior.ThrowAndCatch(exception);

                ServiceChannel serviceChannel = OperationContext.Current.InternalServiceChannel;

                OperationContext.Current.OperationCompleted +=
                    delegate(object sender, EventArgs e)
                {
                    ChannelDispatcher channelDispatcher = _dispatchRuntime.ChannelDispatcher;
                    if (!channelDispatcher.HandleError(exception) && serviceChannel.HasSession)
                    {
                        try
                        {
                            serviceChannel.Close(ChannelHandler.CloseAfterFaultTimeout);
                        }
                        catch (Exception ex)
                        {
                            if (Fx.IsFatal(ex))
                            {
                                throw;
                            }
                            channelDispatcher.HandleError(ex);
                        }
                    }
                };

                if (_dispatchRuntime._shared.EnableFaults)
                {
                    MessageFault fault = MessageFault.CreateFault(code, reason, action);
                    return(Task.FromResult((object)Message.CreateMessage(message.Version, fault, message.Version.Addressing.DefaultFaultAction)));
                }
                else
                {
                    OperationContext.Current.RequestContext.Close();
                    OperationContext.Current.RequestContext = null;
                    return(Task.FromResult((object)null));
                }
            }
 /// <summary>
 /// Privátní kontrola počtu případů:(0,infinity)
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 private bool CheckActiveCases(int value)
 {
     if (value < 0)
     {
         var reason = new FaultReason("ActiveCases must be in interval <0,infinity>.");
         throw new FaultException <GeneratorServiceFault>(new GeneratorServiceFault(reason.ToString() + " Wrong Value: " + value), reason);
     }
     return(true);
 }
 /// <summary>
 /// Privátní kontrola validity zatížení
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 private bool CheckLoad(double value)
 {
     if (value < 0 || value > 100)//musi byt v intervalu 0-100
     {
         var reason = new FaultReason("Load must be in interval <0,100> %.");
         throw new FaultException <GeneratorServiceFault>(new GeneratorServiceFault(reason.ToString() + " Wrong Value: " + value), reason);
     }
     return(true);
 }
Exemplo n.º 11
0
        internal static Exception CreateFailedAuthenticationFaultException()
        {
            // always use default version?
            SecurityVersion wss         = SecurityVersion.Default;
            FaultCode       faultCode   = FaultCode.CreateSenderFaultCode(wss.InvalidSecurityFaultCode.Value, wss.HeaderNamespace.Value);
            FaultReason     faultReason = new FaultReason(SR.GetString(SR.AuthenticationOfClientFailed), CultureInfo.CurrentCulture);

            return(new FaultException(faultReason, faultCode));
        }
Exemplo n.º 12
0
 public XmlObjectSerializerFault(FaultCode code, FaultReason reason, object detail, XmlObjectSerializer serializer, string actor, string node)
 {
     this.code       = code;
     this.reason     = reason;
     this.detail     = detail;
     this.serializer = serializer;
     this.actor      = actor;
     this.node       = node;
 }
Exemplo n.º 13
0
 public XmlObjectSerializerFault(FaultCode code, FaultReason reason, object detail, XmlObjectSerializer serializer, string actor, string node)
 {
     _code       = code;
     _reason     = reason;
     _detail     = detail;
     _serializer = serializer;
     _actor      = actor;
     _node       = node;
 }
 protected MakeConnectionMessageFault(Message message, string subcode, string faultReason, string exceptionMessage)
 {
     this.code              = new FaultCode("Receiver", "");
     this.subcode           = subcode;
     this.reason            = new FaultReason(faultReason);
     this.exceptionMessage  = exceptionMessage;
     this.isRemote          = false;
     this.originalMessageId = message.Headers.MessageId;
 }
Exemplo n.º 15
0
        static MessageFault CreateFault12(Message message, int maxBufferSize)
        {
            FaultCode           fc   = null;
            FaultReason         fr   = null;
            string              node = null;
            XmlDictionaryReader r    = message.GetReaderAtBodyContents();

            r.ReadStartElement("Fault", message.Version.Envelope.Namespace);

            for (r.MoveToContent(); r.NodeType != XmlNodeType.EndElement; r.MoveToContent())
            {
                if (r.NamespaceURI != message.Version.Envelope.Namespace)
                {
                    r.Skip();
                    continue;
                }
                switch (r.LocalName)
                {
                case "Code":
                    fc = ReadFaultCode12(r, message.Version.Envelope.Namespace);
                    break;

                case "Reason":
                    fr = ReadFaultReason12(r, message.Version.Envelope.Namespace);
                    break;

                case "Node":
                    node = r.ReadElementContentAsString();
                    break;

                case "Role":
                    r.Skip();                      // no corresponding member to store.
                    break;

                case "Detail":
                    if (!r.IsEmptyElement)
                    {
                        return(new XmlReaderDetailMessageFault(message, r, fc, fr, null, node));
                    }
                    r.Read();
                    break;

                default:
                    throw new XmlException(String.Format("Unexpected node {0} name {1}", r.NodeType, r.Name));
                }
            }

            if (fr == null)
            {
                throw new XmlException("Reason is missing in the Fault message");
            }

            r.ReadEndElement();

            return(new SimpleMessageFault(fc, fr, false, null, null, null, node));
        }
Exemplo n.º 16
0
        public void Simple()
        {
            FaultReason     r = new FaultReason("testing");
            FaultReasonText t = r.GetMatchingTranslation();

            Assert.IsNotNull(t);
            Assert.AreEqual("testing", t.Text, "#1");
            Assert.AreEqual(CultureInfo.CurrentCulture.Name,
                            t.XmlLang, "#2");
        }
Exemplo n.º 17
0
 ReceivedFault(FaultCode code, FaultReason reason, string actor, string node, XmlBuffer detail, EnvelopeVersion version)
 {
     this.code       = code;
     this.reason     = reason;
     this.actor      = actor;
     this.node       = node;
     receivedVersion = version;
     hasDetail       = InferHasDetail(detail);
     this.detail     = hasDetail ? detail : null;
 }
Exemplo n.º 18
0
 private ReceivedFault(FaultCode code, FaultReason reason, string actor, string node, XmlBuffer detail, EnvelopeVersion version)
 {
     _code            = code;
     _reason          = reason;
     _actor           = actor;
     _node            = node;
     _receivedVersion = version;
     _hasDetail       = InferHasDetail(detail);
     _detail          = _hasDetail ? detail : null;
 }
Exemplo n.º 19
0
 private static MessageFault GetSecureConversationCloseNotSupportedFault()
 {
     if (s_secureConversationCloseNotSupportedFault == null)
     {
         FaultCode   faultCode   = FaultCode.CreateSenderFaultCode(DotNetSecurityStrings.SecureConversationCancelNotAllowedFault, DotNetSecurityStrings.Namespace);
         FaultReason faultReason = new FaultReason(SR.Format(SR.SecureConversationCancelNotAllowedFaultReason), System.Globalization.CultureInfo.InvariantCulture);
         s_secureConversationCloseNotSupportedFault = MessageFault.CreateFault(faultCode, faultReason);
     }
     return(s_secureConversationCloseNotSupportedFault);
 }
Exemplo n.º 20
0
 //************************************************************************
 /// <summary>
 /// BusinessExceptionの場合FaultException<ApplicationMessage>を生成する。
 /// </summary>
 /// <param name="error">Exception</param>
 /// <param name="version">MessageVersion</param>
 /// <param name="message">Message</param>
 //************************************************************************
 public void ProvideFault(Exception error, MessageVersion version, ref Message message)
 {
     if (error is BusinessException)
     {
         FaultReason reason = new FaultReason("サーバ側でアプリケーションエラーが発生しました。");
         FaultException <ApplicationMessage> fe
             = new FaultException <ApplicationMessage>(((BusinessException)error).ApplicationMessage, reason);
         MessageFault fault = fe.CreateMessageFault();
         message = Message.CreateMessage(version, fault, fe.Action);
     }
 }
Exemplo n.º 21
0
        public void ThrowCultureSpecificFault()
        {
            List <FaultReasonText> lstReasons = new List <FaultReasonText>();

            lstReasons.Add(new FaultReasonText("This is in english", new System.Globalization.CultureInfo("en-US")));
            lstReasons.Add(new FaultReasonText("This is in french", new System.Globalization.CultureInfo("fr-FR")));
            lstReasons.Add(new FaultReasonText("This is in hindi", new System.Globalization.CultureInfo("hi-IN")));
            FaultReason reason = new FaultReason(lstReasons);

            throw new FaultException(reason, new FaultCode("SomeError"));
        }
Exemplo n.º 22
0
        /// <summary>
        /// 接收请求后事件
        /// </summary>
        /// <param name="request">请求消息</param>
        /// <param name="channel">信道</param>
        /// <param name="instanceContext">WCF实例上下文</param>
        public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
        {
            //获取消息头
            MessageHeaders headers = request.Headers;
            string         action  = headers.Action;

            EndpointDispatcher endpointDispatcher  = OperationContext.Current.EndpointDispatcher;
            DispatchOperation  operationDispatcher = endpointDispatcher.DispatchRuntime.Operations.Single(x => x.Action == action);

            /*
             * 通过OperationBehavior设置Impersonation属性,
             * 默认值为ImpersonationOption.NotAllowed,
             * 当ImpersonationOption.NotAllowed时验证身份,
             * 如无需验证身份,则将Impersonation属性赋值为ImpersonationOption.Allowed。
             */
            if (operationDispatcher.Impersonation == ImpersonationOption.NotAllowed)
            {
                #region # 验证消息头

                if (!headers.Any(x => x.Name == CommonConstants.WCFAuthenticationHeader && x.Namespace == GlobalSetting.ApplicationId))
                {
                    string message = "身份认证消息头不存在,请检查程序!";
                    NoPermissionException innerException = new NoPermissionException(message);
                    FaultReason           faultReason    = new FaultReason(message);
                    FaultCode             faultCode      = new FaultCode(HttpStatusCode.Unauthorized.ToString());
                    throw new FaultException <NoPermissionException>(innerException, faultReason, faultCode);
                }

                #endregion

                //读取消息头中的公钥
                Guid publicKey = headers.GetHeader <Guid>(CommonConstants.WCFAuthenticationHeader, GlobalSetting.ApplicationId);

                //认证
                lock (_Sync)
                {
                    //以公钥为键,查询分布式缓存,如果有值则通过,无值则不通过
                    LoginInfo loginInfo = CacheMediator.Get <LoginInfo>(publicKey.ToString());
                    if (loginInfo == null)
                    {
                        string message = "身份过期,请重新登录!";
                        NoPermissionException innerException = new NoPermissionException(message);
                        FaultReason           faultReason    = new FaultReason(message);
                        FaultCode             faultCode      = new FaultCode(HttpStatusCode.Unauthorized.ToString());
                        throw new FaultException <NoPermissionException>(innerException, faultReason, faultCode);
                    }

                    //通过后,重新设置缓存过期时间
                    CacheMediator.Set(publicKey.ToString(), loginInfo, DateTime.Now.AddMinutes(GlobalSetting.AuthenticationTimeout));
                }
            }

            return(null);
        }
Exemplo n.º 23
0
 public void beforeEmprunter(string livre, string user, string biblio)
 {
     try
     {
         BusinessLayer.Retards.beforeEmprunter(livre, user, biblio);
     }
     catch (Exception ex)
     {
         FaultReason faultReason = new FaultReason(ex.Message);
         throw new FaultException <Exception>(ex, faultReason);
     }
 }
Exemplo n.º 24
0
        private static ReceivedFault CreateFault12Driver(XmlDictionaryReader reader, int maxBufferSize, EnvelopeVersion version)
        {
            reader.ReadStartElement(XD.MessageDictionary.Fault, version.DictionaryNamespace);
            reader.ReadStartElement(XD.Message12Dictionary.FaultCode, version.DictionaryNamespace);
            FaultCode code = ReadFaultCode12Driver(reader, version);

            reader.ReadEndElement();
            List <FaultReasonText> translations = new List <FaultReasonText>();

            if (reader.IsEmptyElement)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.AtLeastOneFaultReasonMustBeSpecified));
            }
            else
            {
                reader.ReadStartElement(XD.Message12Dictionary.FaultReason, version.DictionaryNamespace);
                while (reader.IsStartElement(XD.Message12Dictionary.FaultText, version.DictionaryNamespace))
                {
                    translations.Add(ReadTranslation12(reader));
                }

                reader.ReadEndElement();
            }

            string actor = "";
            string node  = "";

            if (reader.IsStartElement(XD.Message12Dictionary.FaultNode, version.DictionaryNamespace))
            {
                node = reader.ReadElementContentAsString();
            }

            if (reader.IsStartElement(XD.Message12Dictionary.FaultRole, version.DictionaryNamespace))
            {
                actor = reader.ReadElementContentAsString();
            }

            XmlBuffer detail = null;

            if (reader.IsStartElement(XD.Message12Dictionary.FaultDetail, version.DictionaryNamespace))
            {
                detail = new XmlBuffer(maxBufferSize);
                XmlDictionaryWriter writer = detail.OpenSection(reader.Quotas);
                writer.WriteNode(reader, false);
                detail.CloseSection();
                detail.Close();
            }
            reader.ReadEndElement();
            FaultReason reason = new FaultReason(translations);

            return(new ReceivedFault(code, reason, actor, node, detail, version));
        }
Exemplo n.º 25
0
 public WorkflowOperationFault(MessageQueueErrorCode errorCode)
 {
     if (errorCode == MessageQueueErrorCode.QueueNotAvailable)
     {
         faultCode   = FaultCode.CreateSenderFaultCode(operationNotAvailable, ContextMessageHeader.ContextHeaderNamespace);
         faultReason = new FaultReason(new FaultReasonText(SR2.GetString(SR2.OperationNotAvailable), CultureInfo.CurrentCulture));
     }
     else
     {
         faultCode   = FaultCode.CreateSenderFaultCode(operationNotImplemented, ContextMessageHeader.ContextHeaderNamespace);
         faultReason = new FaultReason(new FaultReasonText(SR2.GetString(SR2.OperationNotImplemented), CultureInfo.CurrentCulture));
     }
 }
Exemplo n.º 26
0
        private const int ChannelCurrentDataRecordLength = 3;         // In bytes

        #region .ctors

        /// <summary>
        /// Section-side конструктор
        /// </summary>
        /// <param name="owner">Секция-владелец</param>
        /// <param name="name">название аварии</param>
        public FaultLog(ISection owner, string name)
        {
            Name         = name;
            Signals      = new ObservableCollection <ISignal>();
            RpdMeters    = new ObservableCollection <IRpdMeter>();
            OwnerSection = owner;
            AccuredAt    = DateTime.Now;
            SavedAt      = DateTime.Now;

            FileHash = string.Empty;

            Reason = new FaultReason(null, null);
        }
Exemplo n.º 27
0
        /// <summary>
        /// Generate fault message for a request message.
        /// </summary>
        /// <param name="requestMsg">request message</param>
        /// <returns>generated fault message</returns>
        private static Message GenerateFaultMessage(Message requestMsg)
        {
            MessageVersion version        = requestMsg.Headers.MessageVersion;
            SessionFault   sessionFault   = new SessionFault(SOAFaultCode.Service_InitializeFailed, StringTable.FailedToInitializeServiceHost);
            FaultReason    faultReason    = new FaultReason(StringTable.FailedToInitializeServiceHost);
            FaultCode      faultCode      = FaultCode.CreateReceiverFaultCode("ServiceHostInitializationFailed", Constant.HpcHeaderNS);
            FaultException faultException = new FaultException <SessionFault>(sessionFault, faultReason, faultCode, SessionFault.Action);
            MessageFault   fault          = faultException.CreateMessageFault();
            Message        faultMessage   = Message.CreateMessage(version, fault, faultException.Action);

            faultMessage.Headers.RelatesTo = requestMsg.Headers.MessageId;
            return(faultMessage);
        }
 public WorkflowOperationFault(MessageQueueErrorCode errorCode)
 {
     if (errorCode == MessageQueueErrorCode.QueueNotAvailable)
     {
         faultCode = FaultCode.CreateSenderFaultCode(operationNotAvailable, ContextMessageHeader.ContextHeaderNamespace);
         faultReason = new FaultReason(new FaultReasonText(SR2.GetString(SR2.OperationNotAvailable), CultureInfo.CurrentCulture));
     }
     else
     {
         faultCode = FaultCode.CreateSenderFaultCode(operationNotImplemented, ContextMessageHeader.ContextHeaderNamespace);
         faultReason = new FaultReason(new FaultReasonText(SR2.GetString(SR2.OperationNotImplemented), CultureInfo.CurrentCulture));
     }
 }
        public InvalidAcknowledgementFault(FaultCode code, FaultReason reason, XmlDictionaryReader detailReader, ReliableMessagingVersion reliableMessagingVersion) : base(code, "InvalidAcknowledgement", reason, true, false)
        {
            UniqueId id;
            bool     flag;

            WsrmAcknowledgmentInfo.ReadAck(reliableMessagingVersion, detailReader, out id, out this.ranges, out flag);
            base.SequenceID = id;
            while (detailReader.IsStartElement())
            {
                detailReader.Skip();
            }
            detailReader.ReadEndElement();
        }
Exemplo n.º 30
0
 public void EditValuesForEntry(int index, uint acctNo, uint pin, int bal, string fName, string lName, byte[] profileImg)
 {
     Console.WriteLine("Attempting to edit user at index: " + index);
     try
     {
         database.EditAcctNoByIndex(index, acctNo);
         database.EditPinByIndex(index, pin);
         database.EditBalanceByIndex(index, bal);
         database.EditFirstNameByIndex(index, fName);
         database.EditLastNameByIndex(index, lName);
         database.EditProfileImgByIndex(index, profileImg);
         // Log the operation
         Console.WriteLine("Successfully edited user at index: " + index);
         Console.WriteLine(String.Format("First name: {0}", fName));
         Console.WriteLine(String.Format("Last name: {0}", lName));
         Console.WriteLine(String.Format("Account No: {0}", acctNo));
         Console.WriteLine(String.Format("PIN: {0}", pin));
         Console.WriteLine(String.Format("Balance: {0}", bal));
         if (profileImg != null)
         {
             Console.WriteLine(String.Format("Profile image: {0}", profileImg.ToString()));
         }
     }
     catch (ArgumentOutOfRangeException e)
     {
         // Log the error message
         Console.WriteLine("Failed to edit user: "******"Edit",
             ProblemType = e.Message
         };
         FaultReason reason = new FaultReason(e.Message);
         throw new FaultException <DatabaseFault>(f, reason);
     }
     catch (ArgumentNullException e)
     {
         // Log the error message
         Console.WriteLine("Failed to edit user: "******"Edit",
             ProblemType = e.Message
         };
         FaultReason reason = new FaultReason(e.Message);
         throw new FaultException <DatabaseFault>(f, reason);
     }
 }
Exemplo n.º 31
0
        static void Main(string[] args)
        {
            FaultCode       code        = FaultCode.CreateSenderFaultCode("calcuError", "http://www.artech.com");
            FaultReasonText reasonText1 = new FaultReasonText("Divided by zero!", "en-US");
            FaultReasonText reasonText2 = new FaultReasonText("试图除以零!", "zh-CN");
            FaultReason     reason      = new FaultReason(new FaultReasonText[] { reasonText1, reasonText2 });
            MessageFault    fault       = MessageFault.CreateFault(code, reason);
            string          action      = "http://www.artech.com/divideFault";

            using (Message message = Message.CreateMessage(MessageVersion.Default, fault, action))
            {
                WriteMessage(message, "message.xml");
            }
        }
Exemplo n.º 32
0
 public ServiceError(Status status, String error, FaultReason reason)
 {
     Status = status;
     Error = error;
     Reason = reason;
 }
 internal static Exception CreateFailedAuthenticationFaultException()
 {
     // always use default version?
     SecurityVersion wss = SecurityVersion.Default;
     FaultCode faultCode = FaultCode.CreateSenderFaultCode(wss.InvalidSecurityFaultCode.Value, wss.HeaderNamespace.Value);
     FaultReason faultReason = new FaultReason(SR.GetString(SR.AuthenticationOfClientFailed), CultureInfo.CurrentCulture);
     return new FaultException(faultReason, faultCode);
 }
 public NetDispatcherFaultException(FaultReason reason, FaultCode code, Exception innerException)
     : base(reason, code, FaultCodeConstants.Actions.NetDispatcher, innerException)
 {
 }
Exemplo n.º 35
0
 public DurableDispatcherAddressingFault()
 {
     faultCode = FaultCode.CreateSenderFaultCode(missingContextHeaderFaultName, ContextMessageHeader.ContextHeaderNamespace);
     faultReason = new FaultReason(new FaultReasonText(SR2.GetString(SR2.CurrentOperationCannotCreateInstance), CultureInfo.CurrentCulture));
 }