private 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 (_debug) { faultInfo.DefaultFaultAction = action; fault = MessageFault.CreateFault(code, new FaultReason(error.Message), new ExceptionDetail(error)); } else { string reason = _isOnServer ? SR.SFxInternalServerError : SR.SFxInternalCallbackError; fault = MessageFault.CreateFault(code, new FaultReason(reason)); } faultInfo.IsConsideredUnhandled = true; faultInfo.Fault = Message.CreateMessage(_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; } } }
internal static FaultException CreateDispatchFaultException() { FaultCode code = new FaultCode(FaultCodeConstants.Codes.InternalServiceFault, FaultCodeConstants.Namespaces.NetDispatch); code = FaultCode.CreateReceiverFaultCode(code); MessageFault dispatchFault = MessageFault.CreateFault(code, new FaultReason(new FaultReasonText(SR.InternalServerError, CultureInfo.CurrentCulture))); return new FaultException(dispatchFault, FaultCodeConstants.Actions.NetDispatcher); }
public static SoapException RaiseException(string uri, string webServiceNamespace, string errorMessage, string errorNumber, string errorSource, FaultCode code) { XmlQualifiedName faultCodeLocation = null; //Identify the location of the FaultCode switch (code) { case FaultCode.Client: faultCodeLocation = SoapException.ClientFaultCode; break; case FaultCode.Server: faultCodeLocation = SoapException.ServerFaultCode; break; } XmlDocument xmlDoc = new XmlDocument(); //Create the Detail node XmlNode rootNode = xmlDoc.CreateNode(XmlNodeType.Element, SoapException.DetailElementName.Name, SoapException.DetailElementName.Namespace); //Build specific details for the SoapException //Add first child of detail XML element. XmlNode errorNode = xmlDoc.CreateNode(XmlNodeType.Element, "Error", webServiceNamespace); //Create and set the value for the ErrorNumber node XmlNode errorNumberNode = xmlDoc.CreateNode(XmlNodeType.Element, "ErrorNumber", webServiceNamespace); errorNumberNode.InnerText = errorNumber; //Create and set the value for the ErrorMessage node XmlNode errorMessageNode = xmlDoc.CreateNode(XmlNodeType.Element, "ErrorMessage", webServiceNamespace); errorMessageNode.InnerText = errorMessage; //Create and set the value for the ErrorSource node XmlNode errorSourceNode = xmlDoc.CreateNode(XmlNodeType.Element, "ErrorSource", webServiceNamespace); errorSourceNode.InnerText = errorSource; //Append the Error child element nodes to the root detail node. errorNode.AppendChild(errorNumberNode); errorNode.AppendChild(errorMessageNode); errorNode.AppendChild(errorSourceNode); //Append the Detail node to the root node rootNode.AppendChild(errorNode); //Construct the exception SoapException soapEx = new SoapException(errorMessage, faultCodeLocation, uri, rootNode); //Raise the exception back to the caller return soapEx; }
private static FaultCode Deserialize(XmlReader reader) { using (reader) { var code = new FaultCode (); reader.ReadToFollowing ("UPnPError", "urn:schemas-upnp-org:control-1-0"); while (Helper.ReadToNextElement (reader)) { Deserialize (reader.ReadSubtree (), reader.Name, ref code); } return code; } }
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)); } }
private static void Deserialize(XmlReader reader, string element, ref FaultCode code) { using (reader) { reader.Read (); switch (element.ToLower ()) { case "errorcode": reader.Read (); var value = reader.ReadContentAsInt (); code.Status = Enum.IsDefined (typeof(UpnpControlExceptionStatus), value) ? (UpnpControlExceptionStatus)value : UpnpControlExceptionStatus.Unknown; break; case "errordescription": code.Message = reader.ReadString (); break; default: // This is a workaround for Mono bug 334752 reader.Skip (); break; } } }
public void ProvideFault(Exception error, MessageVersion version, ref Message fault) { if (fault == null && IsUserCodeException(error)) { FaultCode code = new FaultCode(FaultCodeConstants.Codes.InternalServiceFault, FaultCodeConstants.Namespaces.NetDispatch); code = FaultCode.CreateReceiverFaultCode(code); string action = FaultCodeConstants.Actions.NetDispatcher; MessageFault messageFault; if (this.debug) { Exception toTrace = GetExceptionToTrace(error); messageFault = MessageFault.CreateFault(code, new FaultReason(toTrace.Message), new ExceptionDetail(toTrace)); } else { string reason = SR.GetString(SR.SFxInternalServerError); messageFault = MessageFault.CreateFault(code, new FaultReason(reason)); } fault = Message.CreateMessage(version, messageFault, action); } }
/// <summary> /// Initializes a new instance of the <see cref="BaseServiceException"/> class. /// </summary> /// <param name="code">The code.</param> public BaseServiceException(FaultCode code) : base(GetMessage(code)) { this.ErrorCode = code; this.Key = Guid.NewGuid(); }
private void ReplyFailure(RequestContext request, Message fault, string action, string reason, FaultCode code) { FaultException exception = new FaultException(reason, code); ErrorBehavior.ThrowAndCatch(exception); ErrorHandlerFaultInfo faultInfo = new ErrorHandlerFaultInfo(action); faultInfo.Fault = fault; bool replied, replySentAsync; ProvideFaultAndReplyFailure(request, exception, ref faultInfo, out replied, out replySentAsync); this.HandleError(exception, ref faultInfo); }
internal static MessageFault CreateFault(FaultCode code, string reason) { return(CreateFault(code, new FaultReason(reason))); }
public GroovesharkException(FaultCode code) { FaultErrorCode = code; }
void BuildInvokeParams(MessageProcessingContext mrc, out object [] parameters) { DispatchOperation operation = mrc.Operation; EnsureValid(operation); if (operation.DeserializeRequest) { parameters = operation.Invoker.AllocateInputs(); operation.Formatter.DeserializeRequest(mrc.IncomingMessage, parameters); } else { parameters = new object [] { mrc.IncomingMessage } }; mrc.EventsHandler.BeforeInvoke(operation); } void ProcessCustomErrorHandlers(MessageProcessingContext mrc, Exception ex) { var dr = mrc.OperationContext.EndpointDispatcher.DispatchRuntime; bool shutdown = false; if (dr.ChannelDispatcher != null) // non-callback channel { foreach (var eh in dr.ChannelDispatcher.ErrorHandlers) { shutdown |= eh.HandleError(ex); } } if (shutdown) { ProcessSessionErrorShutdown(mrc); } } void ProcessSessionErrorShutdown(MessageProcessingContext mrc) { var dr = mrc.OperationContext.EndpointDispatcher.DispatchRuntime; var session = mrc.OperationContext.Channel.InputSession; var dcc = mrc.OperationContext.Channel as IDuplexContextChannel; if (session == null || dcc == null) { return; } foreach (var h in dr.InputSessionShutdownHandlers) { h.ChannelFaulted(dcc); } } bool IsGenericFaultException(Type type, out Type arg) { for (; type != null; type = type.BaseType) { if (!type.IsGenericType) { continue; } var tdef = type.GetGenericTypeDefinition(); if (!tdef.Equals(typeof(FaultException <>))) { continue; } arg = type.GetGenericArguments() [0]; return(true); } arg = null; return(false); } Message BuildExceptionMessage(MessageProcessingContext mrc, Exception ex, bool includeDetailsInFault) { var dr = mrc.OperationContext.EndpointDispatcher.DispatchRuntime; var cd = dr.ChannelDispatcher; Message msg = null; if (cd != null) // non-callback channel { foreach (var eh in cd.ErrorHandlers) { eh.ProvideFault(ex, cd.MessageVersion, ref msg); } } if (msg != null) { return(msg); } var req = mrc.IncomingMessage; Type gft; var fe = ex as FaultException; if (fe != null && IsGenericFaultException(fe.GetType(), out gft)) { foreach (var fci in mrc.Operation.FaultContractInfos) { if (fci.Detail == gft) { return(Message.CreateMessage(req.Version, fe.CreateMessageFault(), fci.Action)); } } } // FIXME: set correct name FaultCode fc = new FaultCode( "InternalServiceFault", req.Version.Addressing.Namespace); if (includeDetailsInFault) { return(Message.CreateMessage(req.Version, fc, ex.Message, new ExceptionDetail(ex), req.Headers.Action)); } string faultString = @"The server was unable to process the request due to an internal error. The server may be able to return exception details (it depends on the server settings)."; return(Message.CreateMessage(req.Version, fc, faultString, req.Headers.Action)); } void EnsureValid(DispatchOperation operation) { if (operation.Invoker == null) { throw new InvalidOperationException(String.Format("DispatchOperation '{0}' for contract '{1}' requires Invoker.", operation.Name, operation.Parent.EndpointDispatcher.ContractName)); } if ((operation.DeserializeRequest || operation.SerializeReply) && operation.Formatter == null) { throw new InvalidOperationException("The DispatchOperation '" + operation.Name + "' requires Formatter, since DeserializeRequest and SerializeReply are not both false."); } } }
// // Summary: // Initializes a new instance of the System.ServiceModel.FaultException`1 class // that uses a specified detail object and SOAP fault reason, code and action values. // // Parameters: // detail: // The object used as the SOAP fault detail. // // reason: // The reason for the SOAP fault. // // code: // The fault code for the SOAP fault. // // action: // The action of the SOAP fault. public FaultException(TDetail detail, FaultReason reason, FaultCode code, string action) { }
/// <summary> /// Provide fault /// </summary> public void ProvideFault(Exception error, MessageVersion version, ref Message fault) { FaultCode code = FaultCode.CreateSenderFaultCode("GENERR", "http://openiz.org/model"); FaultReason reason = new FaultReason(error.Message); this.m_traceSource.TraceEvent(TraceEventType.Error, error.HResult, "Error on WCF pipeline: {0}", error); bool isSecurityViolation = false; // Formulate appropriate response if (error is DomainStateException) { WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.ServiceUnavailable; } else if (error is PolicyViolationException || error is SecurityException || (error as FaultException)?.Code.SubCode?.Name == "FailedAuthentication") { AuditUtil.AuditRestrictedFunction(error, WebOperationContext.Current.IncomingRequest.UriTemplateMatch.RequestUri); WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Forbidden; } else if (error is SecurityTokenException) { isSecurityViolation = true; WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Unauthorized; WebOperationContext.Current.OutgoingResponse.Headers.Add("WWW-Authenticate", "Bearer"); } else if (error is LimitExceededException) { WebOperationContext.Current.OutgoingResponse.StatusCode = (HttpStatusCode)429; WebOperationContext.Current.OutgoingResponse.StatusDescription = "Too Many Requests"; WebOperationContext.Current.OutgoingResponse.Headers.Add(HttpResponseHeader.RetryAfter, "1200"); } else if (error is UnauthorizedRequestException) { isSecurityViolation = true; AuditUtil.AuditRestrictedFunction(error as UnauthorizedRequestException, WebOperationContext.Current.IncomingRequest.UriTemplateMatch.RequestUri); WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Unauthorized; WebOperationContext.Current.OutgoingResponse.Headers.Add("WWW-Authenticate", (error as UnauthorizedRequestException).AuthenticateChallenge); } else if (error is UnauthorizedAccessException) { AuditUtil.AuditRestrictedFunction(error, WebOperationContext.Current.IncomingRequest.UriTemplateMatch.RequestUri); WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Forbidden; } else if (error is WebFaultException) { WebOperationContext.Current.OutgoingResponse.StatusCode = (error as WebFaultException).StatusCode; } else if (error is FaultException) // Other fault exception do nothing { ; } else if (error is Newtonsoft.Json.JsonException || error is System.Xml.XmlException) { WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.BadRequest; } else if (error is DuplicateKeyException) { WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Conflict; } else if (error is FileNotFoundException || error is KeyNotFoundException) { WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.NotFound; } else if (error is DomainStateException) { WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.ServiceUnavailable; } else if (error is DetectedIssueException) { WebOperationContext.Current.OutgoingResponse.StatusCode = (System.Net.HttpStatusCode) 422; } else { WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.InternalServerError; } fault = Message.CreateMessage(version, MessageFault.CreateFault(code, reason), String.Empty); }
internal static MessageFault CreateFault(FaultCode code, FaultReason reason, object detail) { return(CreateFault(code, reason, detail, DataContractSerializerDefaults.CreateSerializer( (detail == null ? typeof(object) : detail.GetType()), int.MaxValue /*maxItems*/), "", "")); }
private void ReplyFailure(RequestContext request, FaultCode code, string reason, string action) { Message fault = Message.CreateMessage(_messageVersion, code, reason, action); ReplyFailure(request, fault, action, reason, code); }
private void ReplyFailure(RequestContext request, FaultCode code, string reason) { string action = _messageVersion.Addressing.DefaultFaultAction; ReplyFailure(request, code, reason, action); }
public NetDispatcherFaultException(FaultReason reason, FaultCode code, Exception innerException) : base(reason, code, "http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher/fault", innerException) { }
/// <summary> /// Handle exception that occured while handling X-Road message service request. /// </summary> public virtual void HandleException(HttpContext context, Exception exception, FaultCode faultCode, string faultString, string faultActor, string details) { using (var writer = XmlWriter.Create(new StreamWriter(context.Response.Body, XRoadEncoding.UTF8))) SoapMessageHelper.SerializeSoapFaultResponse(writer, faultCode, faultString, faultActor, details, exception); }
public NetDispatcherFaultException(FaultReason reason, FaultCode code, Exception innerException) : base(reason, code, FaultCodeConstants.Actions.NetDispatcher, innerException) { }
void WriteTo11(XmlDictionaryWriter writer) { writer.WriteStartElement(XD.MessageDictionary.Fault, XD.Message11Dictionary.Namespace); writer.WriteStartElement(XD.Message11Dictionary.FaultCode, XD.Message11Dictionary.FaultNamespace); FaultCode faultCode = Code; if (faultCode.SubCode != null) { faultCode = faultCode.SubCode; } string name; if (faultCode.IsSenderFault) { name = "Client"; } else if (faultCode.IsReceiverFault) { name = "Server"; } else { name = faultCode.Name; } string ns; if (faultCode.IsPredefinedFault) { ns = Message11Strings.Namespace; } else { ns = faultCode.Namespace; } string prefix = writer.LookupPrefix(ns); if (prefix == null) { writer.WriteAttributeString("xmlns", "a", XmlUtil.XmlNsNs, ns); } writer.WriteQualifiedName(name, ns); writer.WriteEndElement(); FaultReasonText translation = Reason.Translations[0]; writer.WriteStartElement(XD.Message11Dictionary.FaultString, XD.Message11Dictionary.FaultNamespace); if (translation.XmlLang.Length > 0) { writer.WriteAttributeString("xml", "lang", XmlUtil.XmlNs, translation.XmlLang); } writer.WriteString(translation.Text); writer.WriteEndElement(); if (Actor.Length > 0) { writer.WriteElementString(XD.Message11Dictionary.FaultActor, XD.Message11Dictionary.FaultNamespace, Actor); } if (HasDetail) { OnWriteDetail(writer, EnvelopeVersion.Soap11); } writer.WriteEndElement(); }
protected override void Execute(NativeActivityContext context) { MessageVersion version; SendReceiveExtension sendReceiveExtension = context.GetExtension<SendReceiveExtension>(); if (sendReceiveExtension != null) { HostSettings hostSettings = sendReceiveExtension.HostSettings; this.IncludeExceptionDetailInFaults = hostSettings.IncludeExceptionDetailInFaults; } CorrelationHandle correlatesWith = (this.CorrelatesWith == null) ? null : this.CorrelatesWith.Get(context); if (correlatesWith == null) { correlatesWith = context.Properties.Find(CorrelationHandle.StaticExecutionPropertyName) as CorrelationHandle; } CorrelationResponseContext responseContext; if (correlatesWith != null) { if (sendReceiveExtension != null) { if (!this.TryGetMessageVersion(correlatesWith.InstanceKey, out version)) { throw FxTrace.Exception.AsError(new InvalidOperationException(SR2.MessageVersionInformationNotFound)); } } else if (correlatesWith.TryAcquireResponseContext(context, out responseContext)) { //Register the ResponseContext so that InternalSendMessage can access it. if (!correlatesWith.TryRegisterResponseContext(context, responseContext)) { throw FxTrace.Exception.AsError(new InvalidOperationException(SR2.ResponseContextIsNotNull)); } //Use the same MessageVersion as the incoming message that is retrieved using CorrelatonHandle version = responseContext.MessageVersion; } else { throw FxTrace.Exception.AsError(new InvalidOperationException(SR2.CorrelationResponseContextShouldNotBeNull)); } } else { throw FxTrace.Exception.AsError(new InvalidOperationException(SR2.CorrelationResponseContextShouldNotBeNull)); } Fx.Assert((this.Formatter == null && this.FaultFormatter != null) || (this.Formatter != null && this.FaultFormatter == null), "OperationFormatter and FaultFormatter cannot be both null or both set!"); if (this.FaultFormatter != null) { Fx.Assert(this.parameters.Count == 1, "Exception should be the only parameter!"); Exception exception = this.parameters[0].Get(context) as Exception; Fx.Assert(exception != null, "InArgument must be an Exception!"); MessageFault messageFault; string action; FaultException faultException = exception as FaultException; if (faultException != null) { // This is an expected fault // Reproduce logic from ErrorBehavior.InitializeFault messageFault = this.FaultFormatter.Serialize(faultException, out action); if (action == null) { action = version.Addressing.DefaultFaultAction; } } else { // This is an unexpected fault // Reproduce logic from ErrorBehavior.ProvideFaultOfLastResort FaultCode code = new FaultCode(FaultCodeConstants.Codes.InternalServiceFault, FaultCodeConstants.Namespaces.NetDispatch); code = FaultCode.CreateReceiverFaultCode(code); action = FaultCodeConstants.Actions.NetDispatcher; if (this.IncludeExceptionDetailInFaults) { messageFault = MessageFault.CreateFault(code, new FaultReason(new FaultReasonText(exception.Message, CultureInfo.CurrentCulture)), new ExceptionDetail(exception)); } else { messageFault = MessageFault.CreateFault(code, new FaultReason(new FaultReasonText(SR2.InternalServerError, CultureInfo.CurrentCulture))); } } if (messageFault == null) { throw FxTrace.Exception.AsError(new InvalidOperationException(SR2.CannotCreateMessageFault)); } else { Message outMessage = System.ServiceModel.Channels.Message.CreateMessage(version, messageFault, action); this.Message.Set(context, outMessage); } } else { object[] inObjects; if (this.parameters != null) { inObjects = new object[this.parameters.Count]; for (int i = 0; i < this.parameters.Count; i++) { Fx.Assert(this.Parameters[i] != null, "Parameter cannot be null"); inObjects[i] = this.parameters[i].Get(context); } } else { inObjects = Constants.EmptyArray; } object returnValue = null; if (this.Result != null) { returnValue = this.Result.Get(context); } Message outMessage = this.Formatter.SerializeReply(version, inObjects, returnValue); this.Message.Set(context, outMessage); } }
public SequenceClosedFault(FaultCode code, FaultReason reason, XmlDictionaryReader detailReader, ReliableMessagingVersion reliableMessagingVersion) : base(code, "SequenceClosed", reason, detailReader, reliableMessagingVersion, false, true) { }
public DurableDispatcherAddressingFault() { faultCode = FaultCode.CreateSenderFaultCode(missingContextHeaderFaultName, ContextMessageHeader.ContextHeaderNamespace); faultReason = new FaultReason(new FaultReasonText(SR2.GetString(SR2.CurrentOperationCannotCreateInstance), CultureInfo.CurrentCulture)); }
private OperationExecutionFault(string description, FaultCode subcode) { this.faultCode = FaultCode.CreateSenderFaultCode(subcode); this.faultReason = new FaultReason(new FaultReasonText(description, CultureInfo.CurrentCulture)); }
/// <summary> /// Gets the full message. /// </summary> /// <param name="faultCode">The fault code.</param> /// <param name="arguments">The arguments.</param> /// <returns>System.String.</returns> protected static string GetFullMessage(FaultCode faultCode, params string[] arguments) { return string.Format(GetMessage(faultCode), arguments); }
public XmlSerializerMessageFault(FaultCode code, FaultReason reason, object details) { this.details = details; this.code = code; this.reason = reason; }
public void ProvideFault(Exception error, System.ServiceModel.Channels.MessageVersion version, ref System.ServiceModel.Channels.Message fault) { if (fault == null) { if (error is ConfigurationErrorsException) { FaultException <ReceiverFaultDetail> fe = new FaultException <ReceiverFaultDetail>(new ReceiverFaultDetail(error.Message, true), error.Message, FaultCode.CreateReceiverFaultCode(new FaultCode("Configuration"))); MessageFault mf = fe.CreateMessageFault(); fault = Message.CreateMessage(version, mf, fe.Action); } } }
public FaultingService(TestFault fault, FaultReason reason, FaultCode code) { _fault = fault; _reason = reason; _code = code; }
/// <summary> /// Check if fault subcodes sequence is the same as passed in faultCodes /// </summary> /// <param name="ex">Exception to be verified.</param> /// <param name="faultCodes">'/'-separated sequence of codes.</param> /// <param name="verificationDump">String to save verification dump (expected and actual codes).</param> /// <returns>True, if fault exception is correct.</returns> public static bool IsValidOnvifFault(this FaultException ex, string faultCodes, out string verificationDump) { if (ex == null) { verificationDump = "fault exception is null"; return(false); } else { string nameSpace = "http://www.onvif.org/ver10/error"; string envNameSpace = "http://www.w3.org/2003/05/soap-envelope"; string[] codes = faultCodes.Split('/'); if (ex.Code == null) { verificationDump = "no fault code"; return(false); } if (ex.Code.Namespace.ToLower() != envNameSpace) { verificationDump = string.Format("fault code has incorrect namespace ({0})", ex.Code.Namespace); return(false); } StringBuilder actual = new StringBuilder(string.Format("env:{0}", ex.Code.Name)); FaultCode nextCode = ex.Code.SubCode; while (nextCode != null) { if (nextCode.Namespace.ToLower() != nameSpace) { verificationDump = string.Format("subcode {0} has incorrect namespace ({1})", nextCode.Name, nextCode.Namespace); return(false); } actual.AppendFormat("/ter:{0}", nextCode.Name); nextCode = nextCode.SubCode; } if (codes.Length != 0) { StringBuilder expected = new StringBuilder(string.Format("env:{0}", codes[0])); for (int i = 1; i < codes.Length; i++) { expected.AppendFormat("/ter:{0}", codes[i]); } string actualSequence = actual.ToString(); string expectedSequence = expected.ToString(); if (actualSequence != expectedSequence) { verificationDump = string.Format("fault subcodes sequence is incorrect. Expected: {0}, actual: {1}", expectedSequence, actualSequence); return(false); } } verificationDump = string.Empty; return(true); } }
public void TryCreateFaultMessageDefault() { Message msg; Assert.IsFalse(s12.TryCreateFaultMessage(new Exception("error happened"), out msg), "#1-1"); Assert.IsFalse(s12.TryCreateFaultMessage(new FaultException("fault happened", FaultCode.CreateSenderFaultCode(new FaultCode("IAmBroken"))), out msg), "#1-2"); Assert.IsFalse(s12.TryCreateFaultMessage(new FaultException <string> ("fault happened."), out msg), "#1-3"); Assert.IsTrue(s12.TryCreateFaultMessage(new ActionNotSupportedException(), out msg), "#1-4"); Assert.IsTrue(msg.IsFault, "#1-5"); Assert.AreEqual("http://www.w3.org/2005/08/addressing/fault", msg.Headers.Action, "#1-6"); var f = MessageFault.CreateFault(msg, 1000); Assert.AreEqual("Sender", f.Code.Name, "#1-7"); Assert.AreEqual("http://www.w3.org/2003/05/soap-envelope", f.Code.Namespace, "#1-8"); Assert.AreEqual("ActionNotSupported", f.Code.SubCode.Name, "#1-9"); Assert.AreEqual("http://www.w3.org/2005/08/addressing", f.Code.SubCode.Namespace, "#1-10"); Assert.IsFalse(s11.TryCreateFaultMessage(new Exception("error happened"), out msg), "#2-1"); Assert.IsFalse(s11.TryCreateFaultMessage(new FaultException("fault happened", FaultCode.CreateSenderFaultCode(new FaultCode("IAmBroken"))), out msg), "#2-2"); Assert.IsFalse(s11.TryCreateFaultMessage(new FaultException <string> ("fault happened."), out msg), "#2-3"); Assert.IsTrue(s11.TryCreateFaultMessage(new ActionNotSupportedException(), out msg), "#2-4"); Assert.IsTrue(msg.IsFault, "#2-5"); Assert.AreEqual("http://www.w3.org/2005/08/addressing/fault", msg.Headers.Action, "#2-6"); f = MessageFault.CreateFault(msg, 1000); Assert.AreEqual("ActionNotSupported", f.Code.Name, "#2-7"); Assert.AreEqual("http://www.w3.org/2005/08/addressing", f.Code.Namespace, "#2-8"); Assert.IsFalse(none.TryCreateFaultMessage(new Exception("error happened"), out msg), "#3-1"); Assert.IsFalse(none.TryCreateFaultMessage(new FaultException("fault happened", FaultCode.CreateSenderFaultCode(new FaultCode("IAmBroken"))), out msg), "#3-2"); Assert.IsFalse(none.TryCreateFaultMessage(new FaultException <string> ("fault happened."), out msg), "#3-3"); Assert.IsFalse(none.TryCreateFaultMessage(new ActionNotSupportedException(), out msg), "#3-4"); Assert.IsFalse(none.TryCreateFaultMessage(new EndpointNotFoundException(), out msg), "#3-5"); }
public NetDispatcherFaultException(string reason, FaultCode code, Exception innerException) : base(reason, code, FaultCodeConstants.Actions.NetDispatcher, innerException) { }
Task ReplyFailureAsync(RequestContext request, FaultCode code, string reason) { string action = _messageVersion.Addressing.DefaultFaultAction; return(ReplyFailureAsync(request, code, reason, action)); }
/// <summary> /// Gets the message. /// </summary> /// <param name="faultCode">The fault code.</param> /// <returns></returns> protected static string GetMessage(FaultCode faultCode) { return ResourceManager.GetString("E" + ((int)faultCode).ToString()); }
Task ReplyFailureAsync(RequestContext request, FaultCode code, string reason, string action) { Message fault = Message.CreateMessage(_messageVersion, code, reason, action); return(ReplyFailureAsync(request, fault, action, reason, code)); }
// Token: 0x060009D7 RID: 2519 RVA: 0x00022D44 File Offset: 0x00020F44 public OwaVersionException(string message, string user) : base(OwaExtendedErrorCode.VersionMismatch, message, user, FaultCode.CreateSenderFaultCode("Version", "Owa")) { }
private async Task ReplyFailureAsync(RequestContext request, Message fault, string action, string reason, FaultCode code) { FaultException exception = new FaultException(reason, code); ErrorBehavior.ThrowAndCatch(exception); ErrorHandlerFaultInfo faultInfo = new ErrorHandlerFaultInfo(action); faultInfo.Fault = fault; faultInfo = await ProvideFaultAndReplyFailureAsync(request, exception, faultInfo); HandleError(exception, ref faultInfo); }
public static FaultCode CreateFaultCode(this MessageVersion version, string code = null, FaultCode sub = null) { var envelope = version.Envelope; var ns = envelope == EnvelopeVersion.Soap11 ? SoapConstants.Soap11.EnvelopeNamespace : SoapConstants.Soap12.EnvelopeNamespace; if (string.IsNullOrWhiteSpace(code)) { code = envelope == EnvelopeVersion.Soap11 ? "Server" : "Receiver"; } if (sub != null) { return(new FaultCode(code, ns, sub)); } return(new FaultCode(code, ns)); }
public void TryCreateExceptionDefault() { Message msg; Assert.IsFalse(s12.TryCreateFaultMessage(new Exception("error happened"), out msg), "#1-1"); Assert.IsFalse(s12.TryCreateFaultMessage(new FaultException("fault happened", FaultCode.CreateSenderFaultCode(new FaultCode("IAmBroken"))), out msg), "#1-2"); Assert.IsFalse(s12.TryCreateFaultMessage(new FaultException <string> ("fault happened."), out msg), "#1-3"); Assert.IsFalse(s11.TryCreateFaultMessage(new Exception("error happened"), out msg), "#2-1"); Assert.IsFalse(s11.TryCreateFaultMessage(new FaultException("fault happened", FaultCode.CreateSenderFaultCode(new FaultCode("IAmBroken"))), out msg), "#2-2"); Assert.IsFalse(s11.TryCreateFaultMessage(new FaultException <string> ("fault happened."), out msg), "#2-3"); }
UpnpControlException(FaultCode code) : base(code.Message) { this.status = code.Status; }
public FaultCode (string name, FaultCode subCode) : this (name, String.Empty, subCode) { }
public static FaultCode CreateReceiverFaultCode (FaultCode subCode) { return new FaultCode ("Receiver", subCode); }
public GroovesharkException(FaultCode code, string message = null, Exception inner = null) : base(message,inner) { ErrorCode = code; }
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; }
internal static MessageFault CreateFault(FaultCode code, FaultReason reason) { return(CreateFault(code, reason, null, null, "", "")); }
public FaultCode (string name, string ns, FaultCode subCode) { this.name = name; this.ns = ns; this.subcode = subCode; }
protected WsrmHeaderFault(FaultCode code, string subcode, FaultReason reason, XmlDictionaryReader detailReader, ReliableMessagingVersion reliableMessagingVersion, bool faultsInput, bool faultsOutput) : this(code, subcode, reason, faultsInput, faultsOutput) { this.sequenceID = ParseDetail(detailReader, reliableMessagingVersion); }
public static FaultCode CreateSenderFaultCode (FaultCode subCode) { return new FaultCode ("Sender", 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)); }
protected override FaultCode Get11Code(FaultCode code, string subcode) { return(code); }
/// <summary> /// Initializes a new instance of the <see cref="BaseException" /> class. /// </summary> /// <param name="exceptionMessage">The exception message.</param> /// <param name="faultCode">The fault code.</param> /// <param name="innerException">The inner exception.</param> /// <param name="data">The data.</param> public BaseException(string exceptionMessage, FaultCode faultCode, Exception innerException = null, object data = null) : base(exceptionMessage, innerException) { this.ErrorCode = faultCode; this.Key = Guid.NewGuid(); this.ReferenceData = data; }