public virtual CommunicationException CreateException() { string message; if (this.IsRemote) { message = FaultException.GetSafeReasonText(this.reason); message = SR.GetString(SR.WsrmFaultReceived, message); } else { if (this.exceptionMessage == null) { throw Fx.AssertAndThrow("Exception message must not be accessed unless set."); } message = this.exceptionMessage; } if (this.code.IsSenderFault) { return(new ProtocolException(message)); } else { return(new CommunicationException(message)); } }
public static Exception CreateCSFaultException(MessageVersion version, ReliableMessagingVersion reliableMessagingVersion, Message message, IChannel innerChannel) { FaultCode subCode; Exception exception; MessageFault messageFault = MessageFault.CreateFault(message, 0x10000); FaultCode code = messageFault.Code; if (version.Envelope == EnvelopeVersion.Soap11) { subCode = code; } else { if (version.Envelope != EnvelopeVersion.Soap12) { throw Fx.AssertAndThrow("Unsupported version."); } subCode = code.SubCode; } if (subCode != null) { if ((subCode.Namespace == WsrmIndex.GetNamespaceString(reliableMessagingVersion)) && (subCode.Name == "CreateSequenceRefused")) { string safeReasonText = FaultException.GetSafeReasonText(messageFault); if (version.Envelope == EnvelopeVersion.Soap12) { FaultCode code3 = subCode.SubCode; if (((code3 != null) && (code3.Namespace == "http://schemas.microsoft.com/ws/2006/05/rm")) && (code3.Name == "ConnectionLimitReached")) { return(new ServerTooBusyException(safeReasonText)); } if (code.IsSenderFault) { return(new ProtocolException(safeReasonText)); } } return(new CommunicationException(safeReasonText)); } if ((subCode.Namespace == version.Addressing.Namespace) && (subCode.Name == "EndpointUnavailable")) { return(new EndpointNotFoundException(FaultException.GetSafeReasonText(messageFault))); } } FaultConverter property = innerChannel.GetProperty <FaultConverter>(); if (property == null) { property = FaultConverter.GetDefaultFaultConverter(version); } if (property.TryCreateException(message, messageFault, out exception)) { return(exception); } return(new ProtocolException(System.ServiceModel.SR.GetString("UnrecognizedFaultReceivedOnOpen", new object[] { messageFault.Code.Namespace, messageFault.Code.Name, FaultException.GetSafeReasonText(messageFault) }))); }
public override CommunicationException CreateException() { string safeReasonText; if (base.IsRemote) { safeReasonText = FaultException.GetSafeReasonText(this.Reason); safeReasonText = System.ServiceModel.SR.GetString("UnknownSequenceFaultReceived", new object[] { safeReasonText }); } else { safeReasonText = base.GetExceptionMessage(); } return(new CommunicationException(safeReasonText)); }
public override CommunicationException CreateException() { string message; if (this.IsRemote) { message = FaultException.GetSafeReasonText(this.Reason); message = SR.GetString(SR.UnknownSequenceFaultReceived, message); } else { message = this.GetExceptionMessage(); } return(new CommunicationException(message)); }
public virtual CommunicationException CreateException() { string safeReasonText; if (this.IsRemote) { safeReasonText = FaultException.GetSafeReasonText(this.reason); safeReasonText = System.ServiceModel.SR.GetString("WsrmFaultReceived", new object[] { safeReasonText }); } else { if (this.exceptionMessage == null) { throw Fx.AssertAndThrow("Exception message must not be accessed unless set."); } safeReasonText = this.exceptionMessage; } if (this.code.IsSenderFault) { return(new ProtocolException(safeReasonText)); } return(new CommunicationException(safeReasonText)); }
public bool ProcessInfo(WsrmMessageInfo info, RequestContext context, bool throwException) { Exception faultException; if (info.ParsingException != null) { WsrmFault fault; if (this.SequenceID != null) { string faultReason = System.ServiceModel.SR.GetString("CouldNotParseWithAction", new object[] { info.Action }); fault = SequenceTerminatedFault.CreateProtocolFault(this.SequenceID, faultReason, null); } else { fault = null; } faultException = new ProtocolException(System.ServiceModel.SR.GetString("MessageExceptionOccurred"), info.ParsingException); this.OnLocalFault(throwException ? null : faultException, fault, context); } else if (info.FaultReply != null) { faultException = info.FaultException; this.OnLocalFault(throwException ? null : faultException, info.FaultReply, context); } else if (((info.WsrmHeaderFault != null) && (info.WsrmHeaderFault.SequenceID != this.InputID)) && (info.WsrmHeaderFault.SequenceID != this.OutputID)) { faultException = new ProtocolException(System.ServiceModel.SR.GetString("WrongIdentifierFault", new object[] { FaultException.GetSafeReasonText(info.WsrmHeaderFault.Reason) })); this.OnLocalFault(throwException ? null : faultException, (Message)null, context); } else { if (info.FaultInfo == null) { return(true); } if (this.isSessionClosed) { UnknownSequenceFault faultInfo = info.FaultInfo as UnknownSequenceFault; if (faultInfo != null) { UniqueId sequenceID = faultInfo.SequenceID; if (((this.OutputID != null) && (this.OutputID == sequenceID)) || ((this.InputID != null) && (this.InputID == sequenceID))) { if (this.settings.ReliableMessagingVersion == ReliableMessagingVersion.WSReliableMessagingFebruary2005) { info.Message.Close(); return(false); } if (this.settings.ReliableMessagingVersion != ReliableMessagingVersion.WSReliableMessaging11) { throw Fx.AssertAndThrow("Unknown version."); } return(true); } } } faultException = info.FaultException; if (context != null) { context.Close(); } this.OnRemoteFault(throwException ? null : faultException); } info.Message.Close(); if (throwException) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(faultException); } return(false); }