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;
 }
 void ProvideFaultOfLastResort(Exception error, ref ErrorHandlerFaultInfo faultInfo)
 {
     if (faultInfo.Fault == null)
     {
         FaultCode code = new FaultCode(FaultCodeConstants.Codes.InternalServiceFault, FaultCodeConstants.Namespaces.NetDispatch);
         code = FaultCode.CreateReceiverFaultCode(code);
         string action = FaultCodeConstants.Actions.NetDispatcher;
         MessageFault fault;
         if (this.debug)
         {
             faultInfo.DefaultFaultAction = action;
             fault = MessageFault.CreateFault(code, new FaultReason(error.Message), new ExceptionDetail(error));
         }
         else
         {
             string reason = this.isOnServer ? SR.GetString(SR.SFxInternalServerError) : SR.GetString(SR.SFxInternalCallbackError);
             fault = MessageFault.CreateFault(code, new FaultReason(reason));
         }
         faultInfo.IsConsideredUnhandled = true;
         faultInfo.Fault = Message.CreateMessage(this.messageVersion, fault, action);
     }
     //if this is an InternalServiceFault coming from another service dispatcher we should treat it as unhandled so that the channels are cleaned up
     else if (error != null)
     {
         FaultException e = error as FaultException;
         if (e != null && e.Fault != null && e.Fault.Code != null && e.Fault.Code.SubCode != null &&
             string.Compare(e.Fault.Code.SubCode.Namespace, FaultCodeConstants.Namespaces.NetDispatch, StringComparison.Ordinal) == 0 &&
             string.Compare(e.Fault.Code.SubCode.Name, FaultCodeConstants.Codes.InternalServiceFault, StringComparison.Ordinal) == 0)
         {
             faultInfo.IsConsideredUnhandled = true;
         }
     }
 }
 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;
 }
 // remote
 protected WsrmFault(FaultCode code, string subcode, FaultReason reason)
 {
     this.code = code;
     this.subcode = subcode;
     this.reason = reason;
     this.isRemote = true;
 }
Exemple #5
0
 public virtual bool Check(FaultCode code)
 {
    return code.IsReceiverFault &&
           code.SubCode != null &&
           CheckCodeName(code) &&
           CheckCodeNamespace(code);
 }
 public Message CreateMessage(MessageVersion messageVersion, ReliableMessagingVersion reliableMessagingVersion)
 {
     this.SetReliableMessagingVersion(reliableMessagingVersion);
     string faultActionString = WsrmIndex.GetFaultActionString(messageVersion.Addressing, reliableMessagingVersion);
     if (messageVersion.Envelope == EnvelopeVersion.Soap11)
     {
         this.code = this.Get11Code(this.code, this.subcode);
     }
     else
     {
         if (messageVersion.Envelope != EnvelopeVersion.Soap12)
         {
             throw Fx.AssertAndThrow("Unsupported MessageVersion.");
         }
         if (this.code.SubCode == null)
         {
             FaultCode subCode = new FaultCode(this.subcode, WsrmIndex.GetNamespaceString(reliableMessagingVersion));
             this.code = new FaultCode(this.code.Name, this.code.Namespace, subCode);
         }
         this.hasDetail = this.Get12HasDetail();
     }
     Message message = Message.CreateMessage(messageVersion, this, faultActionString);
     this.OnFaultMessageCreated(messageVersion, message);
     return message;
 }
 public FaultException(string reason, FaultCode code, string action)
     : base(reason)
 {
     this.code = FaultException.EnsureCode(code);
     this.reason = FaultException.CreateReason(reason);
     this.action = action;
 }
 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;
 }
		private FaultException HandleClientFaultException(Exception exception, Guid errorId)
		{
			string clientMessage = "The operation could not be performed. Reason: internal server error.";
			FaultCode code = new FaultCode(exception.GetType().Name);
			string errorMessage = String.Format("{0} Error Id: [{1}].{2}{3}", clientMessage, errorId, Environment.NewLine, Logger.ErrorLogEntityToString(Logger.GetExceptionLogEntity(exception)));
			return new FaultException(new FaultReason(errorMessage), FaultCode.CreateReceiverFaultCode(code));
		}
 public Fault(string action, FaultCode code, string reasonText)
 {
     this.action = action;
     this.code = code;
     this.reasonText = reasonText;
     this.reason = new FaultReason(reasonText, CultureInfo.CurrentCulture);
 }
 public FaultCode(string name, string ns, FaultCode subCode)
 {
     if (name == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("name"));
     }
     if (name.Length == 0)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("name"));
     }
     if (!string.IsNullOrEmpty(ns))
     {
         NamingHelper.CheckUriParameter(ns, "ns");
     }
     this.name = name;
     this.ns = ns;
     this.subCode = subCode;
     if (ns == "http://www.w3.org/2003/05/soap-envelope")
     {
         this.version = EnvelopeVersion.Soap12;
     }
     else if (ns == "http://schemas.xmlsoap.org/soap/envelope/")
     {
         this.version = EnvelopeVersion.Soap11;
     }
     else if (ns == "http://schemas.microsoft.com/ws/2005/05/envelope/none")
     {
         this.version = EnvelopeVersion.None;
     }
     else
     {
         this.version = null;
     }
 }
 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");
 }
Exemple #13
0
		public void TestDefaults ()
		{
			code = new FaultCode ("foo");
			Assert.AreEqual ("foo", code.Name);
			Assert.AreEqual (String.Empty, code.Namespace);
			Assert.AreEqual (null, code.SubCode);			
		}
 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);
 }
Exemple #15
0
        /// <summary>
        /// Run step with a fault expected.
        /// </summary>
        /// <param name="action">Action to be performed in a step.</param>
        /// <param name="stepName">Step name.</param>
        /// <param name="expectedFault">Expected fault. If no fault or different fault  is received
        /// and other fault not allowed, step is failed. </param>
        /// <param name="exceptOtherFaults">Indicates if another fault can be excepted
        protected void RunStep(Action action,
                               string stepName,
                               string expectedFault,
                               bool exceptOtherFaults,
                               bool allowNoFault)
        {
            BeginStep(stepName);
            try
            {
                action();
                if (!string.IsNullOrEmpty(expectedFault) && !allowNoFault)
                {
                    AssertException ex = new AssertException(string.Format("\"{0}\" fault is expected, but no SOAP fault returned", expectedFault));
                    throw ex;
                }
            }
            catch (FaultException exc)
            {
                LogStepEvent("SOAP fault returned");
                LogStepEvent(string.Format("Code: {0}", exc.Code.Name));
                System.ServiceModel.FaultCode subCode = exc.Code.SubCode;
                while (subCode != null)
                {
                    LogStepEvent(string.Format("Subcode: {0}", subCode.Name));
                    subCode = subCode.SubCode;
                }

                string faultReason = string.Format("Reason: {0}", exc.Reason).Replace("\n", Environment.NewLine);
                LogStepEvent(faultReason);

                /*******************/

                if (string.IsNullOrEmpty(expectedFault))
                {
                    throw exc;
                }
                else
                {
                    string faultDump;
                    bool   fault = exc.IsValidOnvifFault(expectedFault, out faultDump);
                    if (!fault)
                    {
                        if (!exceptOtherFaults)
                        {
                            string          reason = string.Format("The SOAP FAULT returned from the DUT is invalid: {0}", faultDump);
                            AssertException ex     = new AssertException(reason);
                            throw ex;
                        }
                        else
                        {
                            string warning = string.Format("WARNING: The SOAP FAULT returned from the DUT is not as expected: {0}", faultDump);
                            LogStepEvent(warning);
                        }
                    }
                    SaveStepFault(exc);
                }
            }
            StepPassed();
        }
 public static OperationExecutionFault CreateTransactedLockException(Guid instanceId, string operationName)
 {
     if (instanceLockedFaultCode == null)
     {
         instanceLockedFaultCode = new FaultCode(XD2.WorkflowControlServiceFaults.InstanceLockedUnderTransaction, XD2.WorkflowServices.Namespace);
     }
     return new OperationExecutionFault(SR2.InstanceLockedUnderTransaction(operationName, instanceId), instanceLockedFaultCode);
 }
 public static OperationExecutionFault CreateInstanceNotFoundFault(string description)
 {
     if (instanceNotFoundCode == null)
     {
         instanceNotFoundCode = new FaultCode(XD2.WorkflowControlServiceFaults.InstanceNotFound, XD2.WorkflowServices.Namespace);
     }
     return new OperationExecutionFault(description, instanceNotFoundCode);
 }
 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 = "";
 }
 public static OperationExecutionFault CreateInstanceUnloadedFault(string description)
 {
     if (instanceUnloadedFaultCode == null)
     {
         instanceUnloadedFaultCode = new FaultCode("InstanceUnloaded", "http://schemas.datacontract.org/2008/10/WorkflowServices");
     }
     return new OperationExecutionFault(description, instanceUnloadedFaultCode);
 }
 public static OperationExecutionFault CreateSuspendedFault(Guid instanceId, string operationName)
 {
     if (instanceSuspendedFaultCode == null)
     {
         instanceSuspendedFaultCode = new FaultCode("InstanceSuspended", "http://schemas.datacontract.org/2008/10/WorkflowServices");
     }
     return new OperationExecutionFault(System.ServiceModel.Activities.SR.InstanceSuspended(operationName, instanceId), instanceSuspendedFaultCode);
 }
 public static OperationExecutionFault CreateOperationNotAvailableFault(Guid instanceId, string operationName)
 {
     if (operationNotAvailableFaultCode == null)
     {
         operationNotAvailableFaultCode = new FaultCode("OperationNotAvailable", "http://schemas.datacontract.org/2008/10/WorkflowServices");
     }
     return new OperationExecutionFault(System.ServiceModel.Activities.SR.OperationNotAvailable(operationName, instanceId), operationNotAvailableFaultCode);
 }
 public static FaultCode CreateReceiverFaultCode(FaultCode subCode)
 {
     if (subCode == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("subCode"));
     }
     return new FaultCode("Receiver", subCode);
 }
 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;
 }
 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 = "";
 }
 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;
 }
 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;
 }
 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;
 }
            public FaultCode(System.ServiceModel.FaultCode code)
            {
                string ns = null;

                if (!string.IsNullOrWhiteSpace(code.Namespace))
                {
                    ns = code.Namespace + ":";
                }

                this.Value = ns + code.Name;
            }
Exemple #29
0
 /// <summary>
 /// Initializes the <see cref="FaultFactory"/> class.
 /// </summary>
 static FaultFactory()
 {
     UnauthorizedAccountEditFaultCode = new FaultCode("UnauthorizedAccountEdit");
     UnrecognizedCredentialsFaultCode = new FaultCode("UnrecognizedCredentials");
     EmailAlreadyRegisteredFaultCode = new FaultCode("EmailAlreadyRegistered");
     UnauthorizedAccountWithdrawFaultCode = new FaultCode("UnauthorizedAccountWithdraw");
     SessionDoesNotExistFaultCode = new FaultCode("SessionDoesNotExist");
     UnauthorizedAccountAccessFaultCode = new FaultCode("UnauthorizedAccountAccess");
     UnauthorizedFeatureAccessFaultCode = new FaultCode("UnauthorizedFeatureAccessFaultCode");
     AccountNotFoundFaultCode = new FaultCode("AccountNotFoundFaultCode");
     MarketNotFoundFaultCode = new FaultCode("MarketNotFoundFaultCode");
 }
 private Faults11() : base(ProtocolVersion.Version11)
 {
     string reasonText = Microsoft.Transactions.SR.GetString("CannotCreateContextReason");
     FaultCode code = new FaultCode(base.coordinationStrings.CannotCreateContext, base.coordinationStrings.Namespace);
     this.cannotCreateContext = new Fault(base.coordinationStrings.FaultAction, code, reasonText);
     string str2 = Microsoft.Transactions.SR.GetString("CannotRegisterParticipant");
     FaultCode code2 = new FaultCode(base.coordinationStrings.CannotRegisterParticipant, base.coordinationStrings.Namespace);
     this.cannotRegisterParticipant = new Fault(base.coordinationStrings.FaultAction, code2, str2);
     string str3 = Microsoft.Transactions.SR.GetString("UnknownTransactionReason");
     FaultCode code3 = new FaultCode(base.atomicTransactionStrings.UnknownTransaction, base.atomicTransactionStrings.Namespace);
     this.unknownTransaction = new Fault(base.atomicTransactionStrings.FaultAction, code3, str3);
 }
 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();
 }
Exemple #32
0
        protected void LogFault(FaultException exc)
        {
            LogStepEvent("SOAP fault returned");
            LogStepEvent(string.Format("Code: {0}", exc.Code.Name));
            System.ServiceModel.FaultCode subCode = exc.Code.SubCode;
            while (subCode != null)
            {
                LogStepEvent(string.Format("Subcode: {0}", subCode.Name));
                subCode = subCode.SubCode;
            }

            string faultReason = string.Format("Reason: {0}", exc.Reason).Replace("\n", Environment.NewLine);
            LogStepEvent(faultReason);
        }
 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;
 }
Exemple #34
0
        void GetNTP()
        {
            DeviceClient client = null;

            try
            {
                client = new DeviceClient(new HttpBinding(new IChannelController[] { _listener }),
                                          new EndpointAddress(tbAddress.Text));

                try
                {
                    NTPInformation ntp = client.GetNTP();
                }
                catch (FaultException exc)
                {
                    BeginInvoke(new Action(() =>
                    {
                        WriteLine("Fault!", System.Drawing.Color.BlueViolet);
                        WriteLine(exc.Code.Name, System.Drawing.Color.Green);
                        System.ServiceModel.FaultCode code = exc.Code.SubCode;
                        string offset = "  ";
                        while (code != null)
                        {
                            WriteLine(string.Format("{0}Subcode: {1}", offset, code.Name), System.Drawing.Color.Green);
                            offset = "  " + offset;
                            code   = code.SubCode;
                        }
                    }));
                }

                BeginInvoke(new Action(() => WriteLine("OK")));
            }
            catch (Exception exc)
            {
                if (client != null)
                {
                    client.Abort();
                }
                BeginInvoke(new Action(() => ReportError(exc)));
                //throw;
            }
            finally
            {
                StopAnimation();
            }
        }
Exemple #35
0
        /// <summary>
        /// Run step with more flexible fault validation.
        /// </summary>
        /// <param name="action">Action to be performed.</param>
        /// <param name="stepName">Step name.</param>
        /// <param name="validateFunction">Fault validation function.</param>
        /// <remarks>When no fault is received, validateFunction is called with null parameter.</remarks>
        protected void RunStep(Action action, string stepName, ValidateTypeFault validateFunction)
        {
            BeginStep(stepName);
            try
            {
                action();
                string reason;

                if (!validateFunction(null, out reason))
                {
                    AssertException ex = new AssertException(reason);
                    throw ex;
                }
            }
            catch (FaultException exc)
            {
                LogStepEvent("SOAP fault returned");
                LogStepEvent(string.Format("Code: {0}", exc.Code.Name));
                System.ServiceModel.FaultCode subCode = exc.Code.SubCode;
                while (subCode != null)
                {
                    LogStepEvent(string.Format("Subcode: {0}", subCode.Name));
                    subCode = subCode.SubCode;
                }

                string faultReason = string.Format("Reason: {0}", exc.Reason).Replace("\n", Environment.NewLine);
                LogStepEvent(faultReason);

                LogStepEvent("Validate fault...");
                string reason;
                bool   faultOK = validateFunction(exc, out reason);

                if (faultOK)
                {
                    SaveStepFault(exc);
                }
                else
                {
                    AssertException ex = new AssertException(reason);
                    throw ex;
                }
            }
            StepPassed();
        }
        /// <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);
        }
Exemple #37
0
 public FaultException(TDetail detail, FaultReason reason, FaultCode code)
     : this(detail, reason, code, null)
 {
 }
Exemple #38
0
 public FaultException(TDetail detail, string reason, FaultCode code, string action)
     : this(detail, new FaultReason(reason), code, action)
 {
 }
Exemple #39
0
 public FaultException(TDetail detail, FaultReason reason, FaultCode code, string action)
     : base(reason, code, action)
 {
     this.detail = detail;
 }
Exemple #40
0
        /// <summary>
        /// Perform a step.
        /// </summary>
        /// <param name="action">Action to be performed in a step.</param>
        /// <param name="stepName">Step name</param>
        protected bool RunStepHandleNotSupported(Action action,
                                                 string stepName,
                                                 ValidateTypeFault validateTypeFault,
                                                 ValidateNoFault validateNoFault)
        {
            bool ok = false; // easier to set "true" if action supported

            BeginStep(stepName);
            try
            {
                action();
                if (validateNoFault == null)
                {
                    ok = true; // OK, action supported
                }
                else
                {
                    string reason;
                    bool   noFaultOk = validateNoFault(out reason);
                    if (!noFaultOk)
                    {
                        AssertException ex = new AssertException(reason);
                        throw ex;
                    }
                }
            }
            catch (FaultException exc)
            {
                ok = false; // action not supported, except cases of some "Reasonable" fault

                LogStepEvent("SOAP fault returned");
                LogStepEvent(string.Format("Code: {0}", exc.Code.Name));
                System.ServiceModel.FaultCode subCode = exc.Code.SubCode;
                while (subCode != null)
                {
                    LogStepEvent(string.Format("Subcode: {0}", subCode.Name));
                    subCode = subCode.SubCode;
                }

                string faultReason = string.Format("Reason: {0}", exc.Reason).Replace("\n", Environment.NewLine);
                LogStepEvent(faultReason);


                if (!exc.IsValidOnvifFault("Receiver/ActionNotSupported/NoImagingForSource"))
                {
                    if (!exc.IsValidOnvifFault("Receiver/ActionNotSupported"))
                    {
                        //ok = true; // action supported
                        if (validateTypeFault != null)
                        {
                            CustomValidateFault(validateTypeFault, exc);
                        }
                        else
                        {
                            // other faults are also OK
                            LogStepEvent("Warning: fault received is neither Receiver/ActionNotSupported, nor Receiver/ActionNotSupported/NoImagingForSource");
                        }
                    }
                }
            }
            StepPassed();
            return(ok);
        }
Exemple #41
0
 public FaultException(FaultReason reason, FaultCode code)
     : base(FaultException.GetSafeReasonText(reason))
 {
     _code   = FaultException.EnsureCode(code);
     _reason = FaultException.EnsureReason(reason);
 }
Exemple #42
0
 public static FaultCode CreateSenderFaultCode(FaultCode subCode)
 {
     return(new FaultCode("Sender", subCode));
 }
Exemple #43
0
 public FaultCode(string name, FaultCode subCode)
     : this(name, "", subCode)
 {
 }
 private static FaultCode EnsureCode(FaultCode code)
 {
     return (code != null) ? code : DefaultCode;
 }
Exemple #45
0
 public FaultException(TDetail detail, FaultReason reason)
     : this(detail, reason, FaultCode.CreateSenderFaultCode(null))
 {
 }
Exemple #46
0
 public FaultException(string reason, FaultCode code)
     : base(reason)
 {
     _code   = FaultException.EnsureCode(code);
     _reason = FaultException.CreateReason(reason);
 }
 public FaultException(TDetail detail, string reason, FaultCode code)
 {
 }
Exemple #48
0
 public FaultException(FaultReason reason)
     : base(FaultException.GetSafeReasonText(reason))
 {
     _code   = FaultException.DefaultCode;
     _reason = FaultException.EnsureReason(reason);
 }
Exemple #49
0
 public FaultException(FaultReason reason, FaultCode code)
     : base(GetSafeReasonText(reason))
 {
     Code   = EnsureCode(code);
     Reason = EnsureReason(reason);
 }
 public FaultException(TDetail detail, FaultReason reason, FaultCode code)
 {
 }
Exemple #51
0
 internal void AddFaultCodeObjectData(SerializationInfo info, string key, FaultCode code)
 {
     info.AddValue(key, FaultCodeData.GetObjectData(code));
 }
 public FaultException(TDetail detail, FaultReason reason, FaultCode code, string action)
 {
 }
 public FaultException()
     : base(SR.SFxFaultReason)
 {
     _code = FaultException.DefaultCode;
     _reason = FaultException.DefaultReason;
 }
Exemple #54
0
 public FaultException(string reason, FaultCode code)
     : base(reason)
 {
     Code   = EnsureCode(code);
     Reason = CreateReason(reason);
 }
 public FaultException(string reason)
     : base(reason)
 {
     _code = FaultException.DefaultCode;
     _reason = FaultException.CreateReason(reason);
 }
 public FaultException(TDetail detail, string reason, FaultCode code) : base(reason, code)
 {
     this.detail = detail;
 }