Esempio n. 1
0
 internal ProtocolException ReceiveShutdownReturnedNonNull(Message message)
 {
     if (message.IsFault)
     {
         try
         {
             MessageFault    fault  = MessageFault.CreateFault(message, 64 * 1024);
             FaultReasonText reason = fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture);
             string          text   = SR.Format(SR.ReceiveShutdownReturnedFault, reason.Text);
             return(new ProtocolException(text));
         }
         catch (QuotaExceededException)
         {
             string text = SR.Format(SR.ReceiveShutdownReturnedLargeFault, message.Headers.Action);
             return(new ProtocolException(text));
         }
     }
     else
     {
         string text = SR.Format(SR.ReceiveShutdownReturnedMessage, message.Headers.Action);
         return(new ProtocolException(text));
     }
 }
Esempio n. 2
0
            protected override bool OnTryCreateException(Message message, MessageFault fault, out Exception exception)
            {
                exception = null;

                // SOAP MustUnderstand
                if (string.Compare(fault.Code.Namespace, version.Envelope.Namespace, StringComparison.Ordinal) == 0 &&
                    string.Compare(fault.Code.Name, MessageStrings.MustUnderstandFault, StringComparison.Ordinal) == 0)
                {
                    exception = new ProtocolException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
                    return(true);
                }

                bool      checkSender;
                bool      checkReceiver;
                FaultCode code;

                if (version.Envelope == EnvelopeVersion.Soap11)
                {
                    checkSender   = true;
                    checkReceiver = true;
                    code          = fault.Code;
                }
                else
                {
                    checkSender   = fault.Code.IsSenderFault;
                    checkReceiver = fault.Code.IsReceiverFault;
                    code          = fault.Code.SubCode;
                }

                if (code == null)
                {
                    return(false);
                }

                if (code.Namespace == null)
                {
                    return(false);
                }

                if (checkSender)
                {
                    // WS-Addressing
                    if (string.Compare(code.Namespace, version.Addressing.Namespace, StringComparison.Ordinal) == 0)
                    {
                        if (string.Compare(code.Name, AddressingStrings.ActionNotSupported, StringComparison.Ordinal) == 0)
                        {
                            exception = new ActionNotSupportedException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
                            return(true);
                        }
                        else if (string.Compare(code.Name, AddressingStrings.DestinationUnreachable, StringComparison.Ordinal) == 0)
                        {
                            exception = new EndpointNotFoundException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
                            return(true);
                        }
                        else if (string.Compare(code.Name, Addressing10Strings.InvalidAddressingHeader, StringComparison.Ordinal) == 0)
                        {
                            if (code.SubCode != null && string.Compare(code.SubCode.Namespace, version.Addressing.Namespace, StringComparison.Ordinal) == 0 &&
                                string.Compare(code.SubCode.Name, Addressing10Strings.InvalidCardinality, StringComparison.Ordinal) == 0)
                            {
                                exception = new MessageHeaderException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text, true);
                                return(true);
                            }
                        }
                        else if (version.Addressing == AddressingVersion.WSAddressing10)
                        {
                            if (string.Compare(code.Name, Addressing10Strings.MessageAddressingHeaderRequired, StringComparison.Ordinal) == 0)
                            {
                                exception = new MessageHeaderException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
                                return(true);
                            }
                            else if (string.Compare(code.Name, Addressing10Strings.InvalidAddressingHeader, StringComparison.Ordinal) == 0)
                            {
                                exception = new ProtocolException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
                                return(true);
                            }
                        }
                        else
                        {
                            if (string.Compare(code.Name, Addressing200408Strings.MessageInformationHeaderRequired, StringComparison.Ordinal) == 0)
                            {
                                exception = new ProtocolException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
                                return(true);
                            }
                            else if (string.Compare(code.Name, Addressing200408Strings.InvalidMessageInformationHeader, StringComparison.Ordinal) == 0)
                            {
                                exception = new ProtocolException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
                                return(true);
                            }
                        }
                    }
                }

                if (checkReceiver)
                {
                    // WS-Addressing
                    if (string.Compare(code.Namespace, version.Addressing.Namespace, StringComparison.Ordinal) == 0)
                    {
                        if (string.Compare(code.Name, AddressingStrings.EndpointUnavailable, StringComparison.Ordinal) == 0)
                        {
                            exception = new ServerTooBusyException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
                            return(true);
                        }
                    }
                }

                return(false);
            }
Esempio n. 3
0
 protected abstract bool OnTryCreateException(Message message, MessageFault fault, out Exception exception);