コード例 #1
0
 protected FaultException(SerializationInfo info, StreamingContext context) : base(info, context)
 {
     this.code = this.ReconstructFaultCode(info, "code");
     this.reason = this.ReconstructFaultReason(info, "reason");
     this.fault = (MessageFault) info.GetValue("messageFault", typeof(MessageFault));
     this.action = info.GetString("action");
 }
 private static WsrmHeaderFault CreateWsrmHeaderFault(ReliableMessagingVersion reliableMessagingVersion, FaultCode code, string subcode, FaultReason reason, XmlDictionaryReader detailReader)
 {
     if (code.IsSenderFault)
     {
         if (subcode == "InvalidAcknowledgement")
         {
             return new InvalidAcknowledgementFault(code, reason, detailReader, reliableMessagingVersion);
         }
         if (subcode == "MessageNumberRollover")
         {
             return new MessageNumberRolloverFault(code, reason, detailReader, reliableMessagingVersion);
         }
         if (subcode == "UnknownSequence")
         {
             return new UnknownSequenceFault(code, reason, detailReader, reliableMessagingVersion);
         }
         if (reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessagingFebruary2005)
         {
             if (subcode == "LastMessageNumberExceeded")
             {
                 return new LastMessageNumberExceededFault(code, reason, detailReader, reliableMessagingVersion);
             }
         }
         else if ((reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11) && (subcode == "SequenceClosed"))
         {
             return new SequenceClosedFault(code, reason, detailReader, reliableMessagingVersion);
         }
     }
     if (!code.IsSenderFault && !code.IsReceiverFault)
     {
         return null;
     }
     return new SequenceTerminatedFault(code, reason, detailReader, reliableMessagingVersion);
 }
コード例 #3
0
 internal FaultException(FaultReason reason, FaultCode code, string action, Exception innerException)
     : base(FaultException.GetSafeReasonText(reason), innerException)
 {
     _code = FaultException.EnsureCode(code);
     _reason = FaultException.EnsureReason(reason);
     _action = action;
 }
コード例 #4
0
 public Fault(string action, FaultCode code, string reasonText)
 {
     this.action = action;
     this.code = code;
     this.reasonText = reasonText;
     this.reason = new FaultReason(reasonText, CultureInfo.CurrentCulture);
 }
コード例 #5
0
 // remote
 protected WsrmFault(FaultCode code, string subcode, FaultReason reason)
 {
     this.code = code;
     this.subcode = subcode;
     this.reason = reason;
     this.isRemote = true;
 }
コード例 #6
0
 internal FaultException(string reason, FaultCode code, string action, Exception innerException)
     : base(reason, innerException)
 {
     this.code = FaultException.EnsureCode(code);
     this.reason = FaultException.CreateReason(reason);
     this.action = action;
 }
コード例 #7
0
 public FaultException(FaultReason reason, FaultCode code, string action)
     : base(FaultException.GetSafeReasonText(reason))
 {
     this.code = FaultException.EnsureCode(code);
     this.reason = FaultException.EnsureReason(reason);
     this.action = action;
 }
コード例 #8
0
 public FaultException(string reason, FaultCode code, string action)
     : base(reason)
 {
     this.code = FaultException.EnsureCode(code);
     this.reason = FaultException.CreateReason(reason);
     this.action = action;
 }
コード例 #9
0
 public FaultException(FaultReason reason, FaultCode code, string action)
     : base(GetSafeReasonText(reason))
 {
     Code   = EnsureCode(code);
     Reason = EnsureReason(reason);
     Action = action;
 }
 public WSAddressing10ProblemHeaderQNameFault(ActionMismatchAddressingException e)
 {
     this.invalidHeaderName = "Action";
     this.code   = FaultCode.CreateSenderFaultCode(new FaultCode("ActionMismatch", AddressingVersion.WSAddressing10.Namespace));
     this.reason = new FaultReason(e.Message, CultureInfo.CurrentCulture);
     this.actor  = "";
     this.node   = "";
 }
コード例 #11
0
 protected FaultException(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     this.code = this.ReconstructFaultCode(info, "code");
     this.reason = this.ReconstructFaultReason(info, "reason");
     this.fault = (MessageFault)info.GetValue("messageFault", typeof(MessageFault));
     this.action = (string)info.GetString("action");
 }
 public WSAddressing10ProblemHeaderQNameFault(ActionMismatchAddressingException e)
 {
     this.invalidHeaderName = "Action";
     this.code = FaultCode.CreateSenderFaultCode(new FaultCode("ActionMismatch", AddressingVersion.WSAddressing10.Namespace));
     this.reason = new FaultReason(e.Message, CultureInfo.CurrentCulture);
     this.actor = "";
     this.node = "";
 }
コード例 #13
0
 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;
 }
コード例 #14
0
 private static FaultReason EnsureReason(FaultReason reason)
 {
     if (reason == null)
     {
         return(DefaultReason);
     }
     return(reason);
 }
 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;
 }
コード例 #16
0
ファイル: FaultReasonTest.cs プロジェクト: nickchal/pash
		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");
		}
コード例 #17
0
 public WSAddressing10ProblemHeaderQNameFault(ActionMismatchAddressingException e)
 {
     _invalidHeaderName = AddressingStrings.Action;
     _code = FaultCode.CreateSenderFaultCode(
         new FaultCode(Addressing10Strings.ActionMismatch, AddressingVersion.WSAddressing10.Namespace));
     _reason = new FaultReason(e.Message, CultureInfo.CurrentCulture);
     _actor = "";
     _node = "";
 }
コード例 #18
0
 public WSAddressing10ProblemHeaderQNameFault(ActionMismatchAddressingException e)
 {
     _invalidHeaderName = AddressingStrings.Action;
     _code = FaultCode.CreateSenderFaultCode(
         new FaultCode(Addressing10Strings.ActionMismatch, AddressingVersion.WSAddressing10.Namespace));
     _reason = new FaultReason(e.Message, CultureInfo.CurrentCulture);
     _actor  = "";
     _node   = "";
 }
コード例 #19
0
 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;
 }
コード例 #20
0
        public FaultException(MessageFault fault)
            : base(FaultException.GetSafeReasonText(GetReason(fault)))
        {
            if (fault == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("fault");

            this.code = FaultException.EnsureCode(fault.Code);
            this.reason = FaultException.EnsureReason(fault.Reason);
            this.fault = fault;
        }
コード例 #21
0
 public FaultException(MessageFault fault) : base(GetSafeReasonText(GetReason(fault)))
 {
     if (fault == null)
     {
         throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("fault");
     }
     this.code = EnsureCode(fault.Code);
     this.reason = EnsureReason(fault.Reason);
     this.fault = fault;
 }
コード例 #22
0
 public FaultException(MessageFault fault) : base(GetSafeReasonText(GetReason(fault)))
 {
     if (fault == null)
     {
         throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("fault");
     }
     this.code   = EnsureCode(fault.Code);
     this.reason = EnsureReason(fault.Reason);
     this.fault  = fault;
 }
コード例 #23
0
        public FaultException(MessageFault fault, string action)
            : base(FaultException.GetSafeReasonText(GetReason(fault)))
        {
            if (fault == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("fault");

            this.code = fault.Code;
            this.reason = fault.Reason;
            this.fault = fault;
            this.action = action;
        }
 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();
 }
コード例 #25
0
ファイル: Program.cs プロジェクト: huoxudong125/WCF-Demo
 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");
     }
 }
コード例 #26
0
            internal static FaultException.FaultReasonData[] GetObjectData(FaultReason reason)
            {
                SynchronizedReadOnlyCollection <FaultReasonText> translations = reason.Translations;

                FaultException.FaultReasonData[] dataArray = new FaultException.FaultReasonData[translations.Count];
                for (int i = 0; i < translations.Count; i++)
                {
                    dataArray[i]         = new FaultException.FaultReasonData();
                    dataArray[i].xmlLang = translations[i].XmlLang;
                    dataArray[i].text    = translations[i].Text;
                }
                return(dataArray);
            }
コード例 #27
0
            internal static FaultReasonData[] GetObjectData(FaultReason reason)
            {
                SynchronizedReadOnlyCollection<FaultReasonText> translations = reason.Translations;
                FaultReasonData[] array = new FaultReasonData[translations.Count];

                for (int i = 0; i < translations.Count; i++)
                {
                    array[i] = new FaultReasonData();
                    array[i]._xmlLang = translations[i].XmlLang;
                    array[i]._text = translations[i].Text;
                }

                return array;
            }
コード例 #28
0
ファイル: Service.cs プロジェクト: iivchenko/Learning-WCF
        public void ThrowGenericFaultException()
        {
            var details = new ErrorDetails
            {
                Code = 666,
                Name = "Devil",
                Description = "This is the end!"
            };

            var reason = new FaultReason("This is the FulaReason");
            var code = FaultCode.CreateReceiverFaultCode("ThrowGenericFaultException", "Server.Service");

            throw new FaultException<ErrorDetails>(details, reason, code);
        }
コード例 #29
0
        /// <summary>
        /// Creates a new FaultException with our fault details based on an existing exception.
        /// </summary>
        /// <param name="exception">The exception to wrap.</param>
        /// <returns></returns>
        public static FaultException<AlarmWorkflowFaultDetails> CreateFault(Exception exception)
        {
            Assertions.AssertNotNull(exception, "exception");

            if (exception is FaultException<AlarmWorkflowFaultDetails>)
            {
                return (FaultException<AlarmWorkflowFaultDetails>)exception;
            }

            FaultReason reason = new FaultReason(exception.Message);
            FaultCode code = new FaultCode("(No code)");
            AlarmWorkflowFaultDetails detail = new AlarmWorkflowFaultDetails(exception);

            return new FaultException<AlarmWorkflowFaultDetails>(detail, reason, code);
        }
 public WSAddressing10ProblemHeaderQNameFault(MessageHeaderException e)
 {
     this.invalidHeaderName = e.HeaderName;
     if (e.IsDuplicate)
     {
         this.code = FaultCode.CreateSenderFaultCode(new FaultCode("InvalidAddressingHeader", AddressingVersion.WSAddressing10.Namespace, new FaultCode("InvalidCardinality", AddressingVersion.WSAddressing10.Namespace)));
     }
     else
     {
         this.code = FaultCode.CreateSenderFaultCode(new FaultCode("MessageAddressingHeaderRequired", AddressingVersion.WSAddressing10.Namespace));
     }
     this.reason = new FaultReason(e.Message, CultureInfo.CurrentCulture);
     this.actor  = "";
     this.node   = "";
 }
コード例 #31
0
 protected WsrmFault(bool isSenderFault, string subcode, string faultReason, string exceptionMessage)
 {
     if (isSenderFault)
     {
         this.code = new FaultCode("Sender", "");
     }
     else
     {
         this.code = new FaultCode("Receiver", "");
     }
     this.subcode = subcode;
     this.reason = new FaultReason(faultReason, CultureInfo.CurrentCulture);
     this.exceptionMessage = exceptionMessage;
     this.isRemote = false;
 }
コード例 #32
0
 internal Message ProvideFault(MessageVersion messageVersion)
 {
     string name = _notUnderstoodHeaders[0].Name;
     string ns = _notUnderstoodHeaders[0].Namespace;
     FaultCode code = new FaultCode(MessageStrings.MustUnderstandFault, _envelopeVersion.Namespace);
     FaultReason reason = new FaultReason(SR.Format(SR.SFxHeaderNotUnderstood, name, ns), CultureInfo.CurrentCulture);
     MessageFault fault = MessageFault.CreateFault(code, reason);
     string faultAction = messageVersion.Addressing.DefaultFaultAction;
     Message message = System.ServiceModel.Channels.Message.CreateMessage(messageVersion, fault, faultAction);
     if (_envelopeVersion == EnvelopeVersion.Soap12)
     {
         this.AddNotUnderstoodHeaders(message.Headers);
     }
     return message;
 }
 public WSAddressing10ProblemHeaderQNameFault(MessageHeaderException e)
 {
     this.invalidHeaderName = e.HeaderName;
     if (e.IsDuplicate)
     {
         this.code = FaultCode.CreateSenderFaultCode(new FaultCode("InvalidAddressingHeader", AddressingVersion.WSAddressing10.Namespace, new FaultCode("InvalidCardinality", AddressingVersion.WSAddressing10.Namespace)));
     }
     else
     {
         this.code = FaultCode.CreateSenderFaultCode(new FaultCode("MessageAddressingHeaderRequired", AddressingVersion.WSAddressing10.Namespace));
     }
     this.reason = new FaultReason(e.Message, CultureInfo.CurrentCulture);
     this.actor = "";
     this.node = "";
 }
 internal Message ProvideFault(MessageVersion messageVersion)
 {
     string name = this.notUnderstoodHeaders[0].Name;
     string str2 = this.notUnderstoodHeaders[0].Namespace;
     FaultCode code = new FaultCode("MustUnderstand", this.envelopeVersion.Namespace);
     FaultReason reason = new FaultReason(System.ServiceModel.SR.GetString("SFxHeaderNotUnderstood", new object[] { name, str2 }), CultureInfo.CurrentCulture);
     MessageFault fault = MessageFault.CreateFault(code, reason);
     string defaultFaultAction = messageVersion.Addressing.DefaultFaultAction;
     Message message = Message.CreateMessage(messageVersion, fault, defaultFaultAction);
     if (this.envelopeVersion == System.ServiceModel.EnvelopeVersion.Soap12)
     {
         this.AddNotUnderstoodHeaders(message.Headers);
     }
     return message;
 }
        internal Message ProvideFault(MessageVersion messageVersion)
        {
            string       name               = this.notUnderstoodHeaders[0].Name;
            string       str2               = this.notUnderstoodHeaders[0].Namespace;
            FaultCode    code               = new FaultCode("MustUnderstand", this.envelopeVersion.Namespace);
            FaultReason  reason             = new FaultReason(System.ServiceModel.SR.GetString("SFxHeaderNotUnderstood", new object[] { name, str2 }), CultureInfo.CurrentCulture);
            MessageFault fault              = MessageFault.CreateFault(code, reason);
            string       defaultFaultAction = messageVersion.Addressing.DefaultFaultAction;
            Message      message            = Message.CreateMessage(messageVersion, fault, defaultFaultAction);

            if (this.envelopeVersion == System.ServiceModel.EnvelopeVersion.Soap12)
            {
                this.AddNotUnderstoodHeaders(message.Headers);
            }
            return(message);
        }
コード例 #36
0
        public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            if (error is FaultException)
                return;
            ServiceOperationFault serviceOperationFault = new ServiceOperationFault();
            FaultReason fr = new FaultReason(error.ToString());
            FaultCode fc = new FaultCode("0001");
            // Creates the exception we want to send back to the client
            var exception = new FaultException<ServiceOperationFault>(serviceOperationFault, fr);

            // Creates a message fault
            var messageFault = exception.CreateMessageFault();

            // Creates the new message based on the message fault
            fault = Message.CreateMessage(version, messageFault, exception.Action);
        }
コード例 #37
0
        internal Message ProvideFault(MessageVersion messageVersion)
        {
            string       name        = _notUnderstoodHeaders[0].Name;
            string       ns          = _notUnderstoodHeaders[0].Namespace;
            FaultCode    code        = new FaultCode(MessageStrings.MustUnderstandFault, _envelopeVersion.Namespace);
            FaultReason  reason      = new FaultReason(string.Format(SRServiceModel.SFxHeaderNotUnderstood, name, ns), CultureInfo.CurrentCulture);
            MessageFault fault       = MessageFault.CreateFault(code, reason);
            string       faultAction = messageVersion.Addressing.DefaultFaultAction;
            Message      message     = System.ServiceModel.Channels.Message.CreateMessage(messageVersion, fault, faultAction);

            if (_envelopeVersion == EnvelopeVersion.Soap12)
            {
                this.AddNotUnderstoodHeaders(message.Headers);
            }
            return(message);
        }
 internal static Exception CreateFault(string reasonText, string codeString, bool isNetDispatcherFault)
 {
     string str;
     string str2;
     if (isNetDispatcherFault)
     {
         str = "http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher";
         str2 = "http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher/fault";
     }
     else
     {
         str = "http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/transactions";
         str2 = "http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/transactions/fault";
     }
     FaultReason reason = new FaultReason(reasonText, CultureInfo.CurrentCulture);
     return new FaultException(reason, FaultCode.CreateSenderFaultCode(codeString, str), str2);
 }
コード例 #39
0
        void IErrorHandler.ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            try
            {
                // Add code here to build faultreason for client based on exception
                FaultReason faultReason = new FaultReason(error.Message);
                ExceptionDetail exceptionDetail = new ExceptionDetail(error);

                // For security reasons you can also decide to not give the ExceptionDetail back to the client or change the message, etc
                FaultException<ExceptionDetail> faultException = new FaultException<ExceptionDetail>(exceptionDetail, faultReason, FaultCode.CreateSenderFaultCode(new FaultCode("0")));

                MessageFault messageFault = faultException.CreateMessageFault();
                fault = Message.CreateMessage(version, messageFault, faultException.Action);
            }
            catch
            {
                // Todo log error
            }
        }
コード例 #40
0
        /// <summary>
        /// Método acionado depois de receber a mensagem do serviço.
        /// </summary>
        /// <param name="request">Dados da requisição da mensage.</param>
        /// <param name="channel">Canal usado na comunicação.</param>
        /// <param name="instanceContext">Contexto da instancia.</param>
        /// <returns></returns>
        public object AfterReceiveRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel, System.ServiceModel.InstanceContext instanceContext)
        {
            string token = null;

            if (request.Properties.ContainsKey("httpRequest"))
            {
                var prop = (HttpRequestMessageProperty)request.Properties["httpRequest"];
                token = prop.Headers[TokenHeaderName];
            }
            if (string.IsNullOrEmpty(token))
            {
                var tokenHeaderIndex = request.Headers.FindHeader(TokenHeaderName, Namespace);
                if (tokenHeaderIndex >= 0)
                {
                    var headerReader = request.Headers.GetReaderAtHeader(tokenHeaderIndex);
                    token = headerReader.ReadElementContentAsString();
                }
            }
            if (string.IsNullOrEmpty(token))
            {
                var reason = new System.ServiceModel.FaultReason(ResourceMessageFormatter.Create(() => Properties.Resources.FaultException_EmptyToken).Format(System.Globalization.CultureInfo.CurrentCulture));
                var code   = new System.ServiceModel.FaultCode(EmptyTokenFaultReasonCode, Namespace);
                throw new System.ServiceModel.FaultException(reason, code);
            }
            Colosoft.Security.TokenConsultResult checkResult = null;
            try
            {
                checkResult = Colosoft.Security.Tokens.Check(token);
            }
            catch (Exception ex)
            {
                var message = ResourceMessageFormatter.Create(() => Properties.Resources.Exception_TokenCheckingError, Colosoft.Diagnostics.ExceptionFormatter.FormatException(ex, true)).Format();
                throw new Exception(message, ex);
            }
            if (checkResult == null || !checkResult.Success)
            {
                var reason = new System.ServiceModel.FaultReason(ResourceMessageFormatter.Create(() => Properties.Resources.FaultException_InvalidToken).Format(System.Globalization.CultureInfo.CurrentCulture) + " " + checkResult.Message);
                var code   = new System.ServiceModel.FaultCode(InvalidTokenFaultReasonCode, Namespace);
                throw new System.ServiceModel.FaultException(reason, code);
            }
            ConfigureValidToken(token, checkResult);
            return(null);
        }
コード例 #41
0
 internal static string GetSafeReasonText(FaultReason reason)
 {
     if (reason == null)
     {
         return(System.ServiceModel.SR.GetString("SFxUnknownFaultNullReason0"));
     }
     try
     {
         return(reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
     }
     catch (ArgumentException)
     {
         if (reason.Translations.Count == 0)
         {
             return(System.ServiceModel.SR.GetString("SFxUnknownFaultZeroReasons0"));
         }
         return(System.ServiceModel.SR.GetString("SFxUnknownFaultNoMatchingTranslation1", new object[] { reason.Translations[0].Text }));
     }
 }
コード例 #42
0
        internal static string GetSafeReasonText(FaultReason reason)
        {
            if (reason == null)
                return SR.GetString(SR.SFxUnknownFaultNullReason0);

            try
            {
                return reason.GetMatchingTranslation(System.Globalization.CultureInfo.CurrentCulture).Text;
            }
            catch (ArgumentException)
            {
                if (reason.Translations.Count == 0)
                {
                    return SR.GetString(SR.SFxUnknownFaultZeroReasons0);
                }
                else
                {
                    return SR.GetString(SR.SFxUnknownFaultNoMatchingTranslation1, reason.Translations[0].Text);
                }
            }
        }
 public MessageNumberRolloverFault(FaultCode code, FaultReason reason, XmlDictionaryReader detailReader, ReliableMessagingVersion reliableMessagingVersion) : base(code, "MessageNumberRollover", reason, true, true)
 {
     try
     {
         base.SequenceID = WsrmUtilities.ReadIdentifier(detailReader, reliableMessagingVersion);
         if (reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11)
         {
             ulong num;
             detailReader.ReadStartElement(DXD.Wsrm11Dictionary.MaxMessageNumber, WsrmIndex.GetNamespace(reliableMessagingVersion));
             if (!ulong.TryParse(detailReader.ReadContentAsString(), out num) || (num <= 0L))
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("InvalidSequenceNumber", new object[] { num })));
             }
             detailReader.ReadEndElement();
         }
     }
     finally
     {
         detailReader.Close();
     }
 }
コード例 #44
0
        internal static Exception CreateFault(string reasonText, string codeString, bool isNetDispatcherFault)
        {
            string faultCodeNamespace, action;

            // 'Transactions' action should be used only when we expect to have a TransactionChannel in the channel stack
            // otherwise one should use the NetDispatch action.
            if (isNetDispatcherFault)
            {
                faultCodeNamespace = FaultCodeConstants.Namespaces.NetDispatch;
                action = FaultCodeConstants.Actions.NetDispatcher;
            }
            else
            {
                faultCodeNamespace = FaultCodeConstants.Namespaces.Transactions;
                action = FaultCodeConstants.Actions.Transactions;
            }

            FaultReason reason = new FaultReason(reasonText, CultureInfo.CurrentCulture);
            FaultCode code = FaultCode.CreateSenderFaultCode(codeString, faultCodeNamespace);
            return new FaultException(reason, code, action);
        }
 private static MessagePartSpecification ExtractMessageParts(string action, ScopedMessagePartSpecification scopedParts, bool isForSignature)
 {
     MessagePartSpecification parts = null;
     if (scopedParts.TryGetParts(action, out parts))
     {
         return parts;
     }
     if (scopedParts.TryGetParts("*", out parts))
     {
         return parts;
     }
     SecurityVersion securityVersion = MessageSecurityVersion.Default.SecurityVersion;
     FaultCode subCode = new FaultCode(securityVersion.InvalidSecurityFaultCode.Value, securityVersion.HeaderNamespace.Value);
     FaultCode code = FaultCode.CreateSenderFaultCode(subCode);
     FaultReason reason = new FaultReason(System.ServiceModel.SR.GetString("InvalidOrUnrecognizedAction", new object[] { action }), CultureInfo.CurrentCulture);
     MessageFault fault = MessageFault.CreateFault(code, reason);
     if (isForSignature)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MessageSecurityException(System.ServiceModel.SR.GetString("NoSignaturePartsSpecified", new object[] { action }), null, fault));
     }
     throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MessageSecurityException(System.ServiceModel.SR.GetString("NoEncryptionPartsSpecified", new object[] { action }), null, fault));
 }
コード例 #46
0
ファイル: Handler.cs プロジェクト: berczeck/.Net
        public void ProvideFault(Exception error, MessageVersion version, ref Message msg)
        {
            if (error is FaultException<ErrorServicioRespuesta>)
                return;

            ErrorServicioRespuesta faultDetail = ErrorBuilder.ConstruirError(error);

            if (faultDetail == null) return;

            Type faultType =
                typeof (FaultException<>).MakeGenericType(faultDetail.GetType());

            var faultReason = new FaultReason(faultDetail.Mensaje);
            FaultCode faultCode = FaultCode.CreateReceiverFaultCode(new FaultCode(faultDetail.Codigo));

            var faultException =
                (FaultException) Activator.CreateInstance(faultType, faultDetail, faultReason, faultCode);

            MessageFault faultMessage = faultException.CreateMessageFault();
            
            msg = Message.CreateMessage(version, faultMessage, faultException.Action);
        }
コード例 #47
0
        public WSAddressing10ProblemHeaderQNameFault(MessageHeaderException e)
        {
            _invalidHeaderName = e.HeaderName;

            if (e.IsDuplicate)
            {
                _code = FaultCode.CreateSenderFaultCode(
                    new FaultCode(Addressing10Strings.InvalidAddressingHeader,
                                  AddressingVersion.WSAddressing10.Namespace,
                                  new FaultCode(Addressing10Strings.InvalidCardinality,
                                                AddressingVersion.WSAddressing10.Namespace)));
            }
            else
            {
                _code = FaultCode.CreateSenderFaultCode(
                    new FaultCode(Addressing10Strings.MessageAddressingHeaderRequired,
                                  AddressingVersion.WSAddressing10.Namespace));
            }

            _reason = new FaultReason(e.Message, CultureInfo.CurrentCulture);
            _actor  = "";
            _node   = "";
        }
コード例 #48
0
ファイル: FaultException.cs プロジェクト: shenhx/dotnet-wcf
 public FaultException(string reason)
     : base(reason)
 {
     _code   = FaultException.DefaultCode;
     _reason = FaultException.CreateReason(reason);
 }
コード例 #49
0
 public FaultException(FaultReason reason, FaultCode code, string action)
     : this(MessageFault.CreateFault(code, reason), action)
 {
 }
コード例 #50
0
 public FaultException(FaultReason reason, FaultCode code)
     : this(MessageFault.CreateFault(code, reason))
 {
 }
コード例 #51
0
 public FaultException(FaultReason reason)
     : this(reason, new FaultCode(String.Empty))
 {
 }
コード例 #52
0
ファイル: FaultException.cs プロジェクト: shenhx/dotnet-wcf
 private static FaultReason EnsureReason(FaultReason reason)
 {
     return((reason != null) ? reason : DefaultReason);
 }
コード例 #53
0
 public FaultException(FaultReason reason, FaultCode code, string action)
 {
 }
コード例 #54
0
ファイル: FaultException.cs プロジェクト: shenhx/dotnet-wcf
 public FaultException()
     : base(SR.SFxFaultReason)
 {
     _code   = FaultException.DefaultCode;
     _reason = FaultException.DefaultReason;
 }
コード例 #55
0
ファイル: FaultException.cs プロジェクト: shenhx/dotnet-wcf
 public FaultException(FaultReason reason)
     : base(FaultException.GetSafeReasonText(reason))
 {
     _code   = FaultException.DefaultCode;
     _reason = FaultException.EnsureReason(reason);
 }
コード例 #56
0
ファイル: FaultException.cs プロジェクト: shenhx/dotnet-wcf
 public FaultException(string reason, FaultCode code)
     : base(reason)
 {
     _code   = FaultException.EnsureCode(code);
     _reason = FaultException.CreateReason(reason);
 }
コード例 #57
0
 public FaultException(FaultReason reason)
 {
 }
コード例 #58
0
ファイル: FaultException.cs プロジェクト: shenhx/dotnet-wcf
 public FaultException(FaultReason reason, FaultCode code)
     : base(FaultException.GetSafeReasonText(reason))
 {
     _code   = FaultException.EnsureCode(code);
     _reason = FaultException.EnsureReason(reason);
 }
コード例 #59
0
 public FaultException(FaultReason reason, FaultCode code)
 {
 }
コード例 #60
0
 public FaultException()
     : base(SR.GetString(SR.SFxFaultReason))
 {
     this.code = FaultException.DefaultCode;
     this.reason = FaultException.DefaultReason;
 }