public WSAddressing10ProblemHeaderQNameFault(ActionMismatchAddressingException e)
 {
     this.invalidHeaderName = "Action";
     this.code = FaultCode.CreateSenderFaultCode(new FaultCode("ActionMismatch", AddressingVersion.WSAddressing10.Namespace));
     this.reason = new FaultReason(e.Message, CultureInfo.CurrentCulture);
     this.actor = "";
     this.node = "";
 }
 public WSAddressing10ProblemHeaderQNameFault(ActionMismatchAddressingException e)
 {
     this.invalidHeaderName = "Action";
     this.code   = FaultCode.CreateSenderFaultCode(new FaultCode("ActionMismatch", AddressingVersion.WSAddressing10.Namespace));
     this.reason = new FaultReason(e.Message, CultureInfo.CurrentCulture);
     this.actor  = "";
     this.node   = "";
 }
Ejemplo n.º 3
0
 public WSAddressing10ProblemHeaderQNameFault(ActionMismatchAddressingException e)
 {
     _invalidHeaderName = AddressingStrings.Action;
     _code = FaultCode.CreateSenderFaultCode(
         new FaultCode(Addressing10Strings.ActionMismatch, AddressingVersion.WSAddressing10.Namespace));
     _reason = new FaultReason(e.Message, CultureInfo.CurrentCulture);
     _actor  = "";
     _node   = "";
 }
 public WSAddressing10ProblemHeaderQNameFault(ActionMismatchAddressingException e)
 {
     _invalidHeaderName = AddressingStrings.Action;
     _code = FaultCode.CreateSenderFaultCode(
         new FaultCode(Addressing10Strings.ActionMismatch, AddressingVersion.WSAddressing10.Namespace));
     _reason = new FaultReason(e.Message, CultureInfo.CurrentCulture);
     _actor = "";
     _node = "";
 }
Ejemplo n.º 5
0
        // makes sure that appropriate HTTP level headers are included in the received Message
        Exception ProcessHttpAddressing(Message message)
        {
            Exception result = null;
            AddProperties(message);

            // check if user is receiving WS-1 messages
            if (message.Version.Addressing == AddressingVersion.None)
            {
                bool actionAbsent = false;
                try
                {
                    actionAbsent = (message.Headers.Action == null);
                }
                catch (XmlException e)
                {
                    DiagnosticUtility.TraceHandledException(e, TraceEventType.Information);
                }
                catch (CommunicationException e)
                {
                    DiagnosticUtility.TraceHandledException(e, TraceEventType.Information);
                }

                if (!actionAbsent)
                {
                    result = new ProtocolException(SR.GetString(SR.HttpAddressingNoneHeaderOnWire,
                        XD.AddressingDictionary.Action.Value));
                }

                bool toAbsent = false;
                try
                {
                    toAbsent = (message.Headers.To == null);
                }
                catch (XmlException e)
                {
                    DiagnosticUtility.TraceHandledException(e, TraceEventType.Information);
                }
                catch (CommunicationException e)
                {
                    DiagnosticUtility.TraceHandledException(e, TraceEventType.Information);
                }

                if (!toAbsent)
                {
                    result = new ProtocolException(SR.GetString(SR.HttpAddressingNoneHeaderOnWire,
                        XD.AddressingDictionary.To.Value));
                }
                message.Headers.To = message.Properties.Via;
            }

            if (isRequest)
            {
                string action = null;

                if (message.Version.Envelope == EnvelopeVersion.Soap11)
                {
                    action = SoapActionHeader;
                }
                else if (message.Version.Envelope == EnvelopeVersion.Soap12 && !String.IsNullOrEmpty(ContentType))
                {
                    ContentType parsedContentType = new ContentType(ContentType);

                    if (parsedContentType.MediaType == multipartRelatedMediaType && parsedContentType.Parameters.ContainsKey(startInfoHeaderParam))
                    {
                        // fix to grab action from start-info as stated in RFC2387
                        action = new ContentType(parsedContentType.Parameters[startInfoHeaderParam]).Parameters["action"];
                    }
                    if (action == null)
                    {
                        // only if we can't find an action inside start-info
                        action = parsedContentType.Parameters["action"];
                    }
                }

                if (action != null)
                {
                    action = UrlUtility.UrlDecode(action, Encoding.UTF8);

                    if (action.Length >= 2 && action[0] == '"' && action[action.Length - 1] == '"')
                    {
                        action = action.Substring(1, action.Length - 2);
                    }

                    if (message.Version.Addressing == AddressingVersion.None)
                    {
                        message.Headers.Action = action;
                    }

                    try
                    {

                        if (action.Length > 0 && string.Compare(message.Headers.Action, action, StringComparison.Ordinal) != 0)
                        {
                            result = new ActionMismatchAddressingException(SR.GetString(SR.HttpSoapActionMismatchFault,
                                message.Headers.Action, action), message.Headers.Action, action);
                        }

                    }
                    catch (XmlException e)
                    {
                        DiagnosticUtility.TraceHandledException(e, TraceEventType.Information);
                    }
                    catch (CommunicationException e)
                    {
                        DiagnosticUtility.TraceHandledException(e, TraceEventType.Information);
                    }
                }
            }

            ApplyChannelBinding(message);

            if (DiagnosticUtility.ShouldUseActivity)
            {
                TraceUtility.TransferFromTransport(message);
            }
            if (DiagnosticUtility.ShouldTraceInformation)
            {
                TraceUtility.TraceEvent(TraceEventType.Information, TraceCode.MessageReceived, SR.GetString(SR.TraceCodeMessageReceived),
                    MessageTransmitTraceRecord.CreateReceiveTraceRecord(message), this, null, message);
            }

            // MessageLogger doesn't log AddressingVersion.None in the encoder since we want to make sure we log 
            // as much of the message as possible. Here we log after stamping the addressing information
            if (MessageLogger.LoggingEnabled && message.Version.Addressing == AddressingVersion.None)
            {
                MessageLogger.LogMessage(ref message, MessageLoggingSource.TransportReceive | MessageLoggingSource.LastChance);
            }

            return result;
        }
 private Exception ProcessHttpAddressing(Message message)
 {
     Exception exception = null;
     this.AddProperties(message);
     if (message.Version.Addressing == AddressingVersion.None)
     {
         bool flag = false;
         try
         {
             flag = message.Headers.Action == null;
         }
         catch (XmlException exception2)
         {
             if (DiagnosticUtility.ShouldTraceInformation)
             {
                 DiagnosticUtility.ExceptionUtility.TraceHandledException(exception2, TraceEventType.Information);
             }
         }
         catch (CommunicationException exception3)
         {
             if (DiagnosticUtility.ShouldTraceInformation)
             {
                 DiagnosticUtility.ExceptionUtility.TraceHandledException(exception3, TraceEventType.Information);
             }
         }
         if (!flag)
         {
             exception = new ProtocolException(System.ServiceModel.SR.GetString("HttpAddressingNoneHeaderOnWire", new object[] { XD.AddressingDictionary.Action.Value }));
         }
         bool flag2 = false;
         try
         {
             flag2 = message.Headers.To == null;
         }
         catch (XmlException exception4)
         {
             if (DiagnosticUtility.ShouldTraceInformation)
             {
                 DiagnosticUtility.ExceptionUtility.TraceHandledException(exception4, TraceEventType.Information);
             }
         }
         catch (CommunicationException exception5)
         {
             if (DiagnosticUtility.ShouldTraceInformation)
             {
                 DiagnosticUtility.ExceptionUtility.TraceHandledException(exception5, TraceEventType.Information);
             }
         }
         if (!flag2)
         {
             exception = new ProtocolException(System.ServiceModel.SR.GetString("HttpAddressingNoneHeaderOnWire", new object[] { XD.AddressingDictionary.To.Value }));
         }
         message.Headers.To = message.Properties.Via;
     }
     if (this.isRequest)
     {
         string soapActionHeader = null;
         if (message.Version.Envelope == EnvelopeVersion.Soap11)
         {
             soapActionHeader = this.SoapActionHeader;
         }
         else if ((message.Version.Envelope == EnvelopeVersion.Soap12) && !string.IsNullOrEmpty(this.ContentType))
         {
             System.Net.Mime.ContentType type = new System.Net.Mime.ContentType(this.ContentType);
             if ((type.MediaType == "multipart/related") && type.Parameters.ContainsKey("start-info"))
             {
                 soapActionHeader = new System.Net.Mime.ContentType(type.Parameters["start-info"]).Parameters["action"];
             }
             if (soapActionHeader == null)
             {
                 soapActionHeader = type.Parameters["action"];
             }
         }
         if (soapActionHeader != null)
         {
             soapActionHeader = UrlUtility.UrlDecode(soapActionHeader, Encoding.UTF8);
             if (((soapActionHeader.Length >= 2) && (soapActionHeader[0] == '"')) && (soapActionHeader[soapActionHeader.Length - 1] == '"'))
             {
                 soapActionHeader = soapActionHeader.Substring(1, soapActionHeader.Length - 2);
             }
             if (message.Version.Addressing == AddressingVersion.None)
             {
                 message.Headers.Action = soapActionHeader;
             }
             try
             {
                 if ((soapActionHeader.Length > 0) && (string.Compare(message.Headers.Action, soapActionHeader, StringComparison.Ordinal) != 0))
                 {
                     exception = new ActionMismatchAddressingException(System.ServiceModel.SR.GetString("HttpSoapActionMismatchFault", new object[] { message.Headers.Action, soapActionHeader }), message.Headers.Action, soapActionHeader);
                 }
             }
             catch (XmlException exception6)
             {
                 if (DiagnosticUtility.ShouldTraceInformation)
                 {
                     DiagnosticUtility.ExceptionUtility.TraceHandledException(exception6, TraceEventType.Information);
                 }
             }
             catch (CommunicationException exception7)
             {
                 if (DiagnosticUtility.ShouldTraceInformation)
                 {
                     DiagnosticUtility.ExceptionUtility.TraceHandledException(exception7, TraceEventType.Information);
                 }
             }
         }
     }
     this.ApplyChannelBinding(message);
     if (DiagnosticUtility.ShouldUseActivity)
     {
         TraceUtility.TransferFromTransport(message);
     }
     if (DiagnosticUtility.ShouldTraceInformation)
     {
         TraceUtility.TraceEvent(TraceEventType.Information, 0x40013, System.ServiceModel.SR.GetString("TraceCodeMessageReceived"), MessageTransmitTraceRecord.CreateReceiveTraceRecord(message), this, null, message);
     }
     if (MessageLogger.LoggingEnabled && (message.Version.Addressing == AddressingVersion.None))
     {
         MessageLogger.LogMessage(ref message, MessageLoggingSource.LastChance | MessageLoggingSource.TransportReceive);
     }
     return exception;
 }