private Message CreateRequestMessage()
        {
            Message request = Message.CreateMessage(this.messageVersion, this.messageAction, this.messageBody);

            request.Properties.AllowOutputBatching = false;
            if (this.messageHeader != null)
            {
                request.Headers.Insert(0, this.messageHeader);
            }
            if (this.messageId != null)
            {
                request.Headers.MessageId = this.messageId;
                RequestReplyCorrelator.PrepareRequest(request);
                EndpointAddress localAddress = this.binder.LocalAddress;
                if (localAddress == null)
                {
                    request.Headers.ReplyTo = null;
                    return(request);
                }
                if (this.messageVersion.Addressing == AddressingVersion.WSAddressingAugust2004)
                {
                    request.Headers.ReplyTo = localAddress;
                    return(request);
                }
                if (this.messageVersion.Addressing != AddressingVersion.WSAddressing10)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ProtocolException(System.ServiceModel.SR.GetString("AddressingVersionNotSupported", new object[] { this.messageVersion.Addressing })));
                }
                request.Headers.ReplyTo = localAddress.IsAnonymous ? null : localAddress;
            }
            return(request);
        }
        public static bool AddressReply(Message message, Message faultMessage)
        {
            try
            {
                RequestReplyCorrelator.PrepareReply(faultMessage, message);
            }
            catch (MessageHeaderException exception)
            {
                if (DiagnosticUtility.ShouldTraceInformation)
                {
                    DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Information);
                }
            }
            bool flag = true;

            try
            {
                flag = RequestReplyCorrelator.AddressReply(faultMessage, message);
            }
            catch (MessageHeaderException exception2)
            {
                if (DiagnosticUtility.ShouldTraceInformation)
                {
                    DiagnosticUtility.ExceptionUtility.TraceHandledException(exception2, TraceEventType.Information);
                }
            }
            return(flag);
        }
        public bool AddressResponse(Message request, Message response)
        {
            if (this.GetAddressedProperty(response) != null)
            {
                throw Fx.AssertAndThrow("The binder can't address a response twice");
            }

            try
            {
                RequestReplyCorrelator.PrepareReply(response, request);
            }
            catch (MessageHeaderException exception)
            {
                // ---- it - we don't need to correlate the reply if the MessageId header is bad
                if (DiagnosticUtility.ShouldTraceInformation)
                {
                    DiagnosticUtility.TraceHandledException(exception, TraceEventType.Information);
                }
            }

            bool sendResponse = true;

            try
            {
                sendResponse = RequestReplyCorrelator.AddressReply(response, request);
            }
            catch (MessageHeaderException exception)
            {
                // ---- it - we don't need to address the reply if the addressing headers are bad
                if (DiagnosticUtility.ShouldTraceInformation)
                {
                    DiagnosticUtility.TraceHandledException(exception, TraceEventType.Information);
                }
            }

            if (sendResponse)
            {
                this.AddAddressedProperty(response);
            }

            return(sendResponse);
        }
 public override void ReadTransactionDataFromMessage(Message message, MessageDirection direction)
 {
     try
     {
         base.ReadTransactionDataFromMessage(message, direction);
     }
     catch (FaultException exception)
     {
         Message reply = Message.CreateMessage(message.Version, exception.CreateMessageFault(), exception.Action);
         RequestReplyCorrelator.AddressReply(reply, message);
         RequestReplyCorrelator.PrepareReply(reply, message.Headers.MessageId);
         try
         {
             this.Send(reply);
         }
         finally
         {
             reply.Close();
         }
         throw;
     }
 }
Esempio n. 5
0
        public bool AddressResponse(Message request, Message response)
        {
            if (this.GetAddressedProperty(response) != null)
            {
                throw Fx.AssertAndThrow("The binder can't address a response twice");
            }
            try
            {
                RequestReplyCorrelator.PrepareReply(response, request);
            }
            catch (MessageHeaderException exception)
            {
                if (DiagnosticUtility.ShouldTraceInformation)
                {
                    DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Information);
                }
            }
            bool flag = true;

            try
            {
                flag = RequestReplyCorrelator.AddressReply(response, request);
            }
            catch (MessageHeaderException exception2)
            {
                if (DiagnosticUtility.ShouldTraceInformation)
                {
                    DiagnosticUtility.ExceptionUtility.TraceHandledException(exception2, TraceEventType.Information);
                }
            }
            if (flag)
            {
                this.AddAddressedProperty(response);
            }
            return(flag);
        }
        internal static bool AddressReply(Message reply, Message request)
        {
            ReplyToInfo info = RequestReplyCorrelator.ExtractReplyToInfo(request);

            return(RequestReplyCorrelator.AddressReply(reply, info));
        }