public static CreateSequenceInfo ReadMessage(MessageVersion messageVersion, ReliableMessagingVersion reliableMessagingVersion, ISecureConversationSession securitySession, Message message, MessageHeaders headers)
        {
            CreateSequenceInfo info;

            if (message.IsEmpty)
            {
                string  reason     = System.ServiceModel.SR.GetString("NonEmptyWsrmMessageIsEmpty", new object[] { WsrmIndex.GetCreateSequenceActionString(reliableMessagingVersion) });
                Message faultReply = WsrmUtilities.CreateCSRefusedProtocolFault(messageVersion, reliableMessagingVersion, reason);
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(WsrmMessageInfo.CreateInternalFaultException(faultReply, reason, new ProtocolException(reason)));
            }
            using (XmlDictionaryReader reader = message.GetReaderAtBodyContents())
            {
                info = CreateSequence.Create(messageVersion, reliableMessagingVersion, securitySession, reader);
                message.ReadFromBodyContentsToEnd(reader);
            }
            info.SetMessageId(messageVersion, headers);
            info.SetReplyTo(messageVersion, headers);
            if (info.AcksTo.Uri != info.ReplyTo.Uri)
            {
                string  str2     = System.ServiceModel.SR.GetString("CSRefusedAcksToMustEqualReplyTo");
                Message message3 = WsrmUtilities.CreateCSRefusedProtocolFault(messageVersion, reliableMessagingVersion, str2);
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(WsrmMessageInfo.CreateInternalFaultException(message3, str2, new ProtocolException(str2)));
            }
            info.to = message.Headers.To;
            if ((info.to == null) && (messageVersion.Addressing == AddressingVersion.WSAddressing10))
            {
                info.to = messageVersion.Addressing.AnonymousUri;
            }
            return(info);
        }
        public static MessageFault CreateFault(Message message, int maxBufferSize)
        {
            MessageFault fault2;

            if (message == null)
            {
                throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("message"));
            }
            XmlDictionaryReader readerAtBodyContents = message.GetReaderAtBodyContents();
            XmlDictionaryReader reader2 = readerAtBodyContents;

            try
            {
                MessageFault    fault;
                EnvelopeVersion envelope = message.Version.Envelope;
                if (envelope == EnvelopeVersion.Soap12)
                {
                    fault = ReceivedFault.CreateFault12(readerAtBodyContents, maxBufferSize);
                }
                else if (envelope == EnvelopeVersion.Soap11)
                {
                    fault = ReceivedFault.CreateFault11(readerAtBodyContents, maxBufferSize);
                }
                else
                {
                    if (envelope != EnvelopeVersion.None)
                    {
                        throw TraceUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("EnvelopeVersionUnknown", new object[] { envelope.ToString() })), message);
                    }
                    fault = ReceivedFault.CreateFaultNone(readerAtBodyContents, maxBufferSize);
                }
                message.ReadFromBodyContentsToEnd(readerAtBodyContents);
                fault2 = fault;
            }
            catch (InvalidOperationException exception)
            {
                throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(System.ServiceModel.SR.GetString("SFxErrorDeserializingFault"), exception));
            }
            catch (FormatException exception2)
            {
                throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(System.ServiceModel.SR.GetString("SFxErrorDeserializingFault"), exception2));
            }
            catch (XmlException exception3)
            {
                throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(System.ServiceModel.SR.GetString("SFxErrorDeserializingFault"), exception3));
            }
            finally
            {
                if (reader2 != null)
                {
                    reader2.Dispose();
                }
            }
            return(fault2);
        }
Exemplo n.º 3
0
        public static MessageFault CreateFault(Message message, int maxBufferSize)
        {
            if (message == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(message)));
            }

            XmlDictionaryReader reader = message.GetReaderAtBodyContents();

            using (reader)
            {
                try
                {
                    EnvelopeVersion envelopeVersion = message.Version.Envelope;
                    MessageFault    fault;
                    if (envelopeVersion == EnvelopeVersion.Soap12)
                    {
                        fault = ReceivedFault.CreateFault12(reader, maxBufferSize);
                    }
                    else if (envelopeVersion == EnvelopeVersion.Soap11)
                    {
                        fault = ReceivedFault.CreateFault11(reader, maxBufferSize);
                    }
                    else if (envelopeVersion == EnvelopeVersion.None)
                    {
                        fault = ReceivedFault.CreateFaultNone(reader, maxBufferSize);
                    }
                    else
                    {
                        throw TraceUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.EnvelopeVersionUnknown, envelopeVersion.ToString())), message);
                    }
                    message.ReadFromBodyContentsToEnd(reader);
                    return(fault);
                }
                catch (InvalidOperationException e)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(
                                                                                  SR.SFxErrorDeserializingFault, e));
                }
                catch (FormatException e)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(
                                                                                  SR.SFxErrorDeserializingFault, e));
                }
                catch (XmlException e)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(
                                                                                  SR.SFxErrorDeserializingFault, e));
                }
            }
        }
        public static CloseSequenceInfo ReadMessage(MessageVersion messageVersion, Message message, MessageHeaders headers)
        {
            CloseSequenceInfo info;

            if (message.IsEmpty)
            {
                string str = System.ServiceModel.SR.GetString("NonEmptyWsrmMessageIsEmpty", new object[] { "http://docs.oasis-open.org/ws-rx/wsrm/200702/CloseSequence" });
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(str));
            }
            using (XmlDictionaryReader reader = message.GetReaderAtBodyContents())
            {
                info = CloseSequence.Create(reader);
                message.ReadFromBodyContentsToEnd(reader);
            }
            info.SetMessageId(messageVersion, headers);
            info.SetReplyTo(messageVersion, headers);
            return(info);
        }
        public static TerminateSequenceResponseInfo ReadMessage(MessageVersion messageVersion, Message message, MessageHeaders headers)
        {
            TerminateSequenceResponseInfo info;

            if (headers.RelatesTo == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MessageHeaderException(System.ServiceModel.SR.GetString("MissingRelatesToOnWsrmResponseReason", new object[] { DXD.Wsrm11Dictionary.TerminateSequenceResponse }), messageVersion.Addressing.Namespace, "RelatesTo", false));
            }
            if (message.IsEmpty)
            {
                string str = System.ServiceModel.SR.GetString("NonEmptyWsrmMessageIsEmpty", new object[] { WsrmIndex.GetTerminateSequenceResponseActionString(ReliableMessagingVersion.WSReliableMessaging11) });
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(str));
            }
            using (XmlDictionaryReader reader = message.GetReaderAtBodyContents())
            {
                info = TerminateSequenceResponse.Create(reader);
                message.ReadFromBodyContentsToEnd(reader);
            }
            info.relatesTo = headers.RelatesTo;
            return(info);
        }
        public static CloseSequenceResponseInfo ReadMessage(MessageVersion messageVersion, Message message, MessageHeaders headers)
        {
            CloseSequenceResponseInfo info;

            if (headers.RelatesTo == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MessageHeaderException(System.ServiceModel.SR.GetString("MissingRelatesToOnWsrmResponseReason", new object[] { DXD.Wsrm11Dictionary.CloseSequenceResponse }), messageVersion.Addressing.Namespace, "RelatesTo", false));
            }
            if (message.IsEmpty)
            {
                string str = System.ServiceModel.SR.GetString("NonEmptyWsrmMessageIsEmpty", new object[] { "http://docs.oasis-open.org/ws-rx/wsrm/200702/CloseSequenceResponse" });
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(str));
            }
            using (XmlDictionaryReader reader = message.GetReaderAtBodyContents())
            {
                info = CloseSequenceResponse.Create(reader);
                message.ReadFromBodyContentsToEnd(reader);
            }
            info.relatesTo = headers.RelatesTo;
            return(info);
        }
        public static TerminateSequenceInfo ReadMessage(MessageVersion messageVersion, ReliableMessagingVersion reliableMessagingVersion, Message message, MessageHeaders headers)
        {
            TerminateSequenceInfo info;

            if (message.IsEmpty)
            {
                string str = System.ServiceModel.SR.GetString("NonEmptyWsrmMessageIsEmpty", new object[] { WsrmIndex.GetTerminateSequenceActionString(reliableMessagingVersion) });
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(str));
            }
            using (XmlDictionaryReader reader = message.GetReaderAtBodyContents())
            {
                info = TerminateSequence.Create(reliableMessagingVersion, reader);
                message.ReadFromBodyContentsToEnd(reader);
            }
            if (reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11)
            {
                info.SetMessageId(messageVersion, headers);
                info.SetReplyTo(messageVersion, headers);
            }
            return(info);
        }