Ejemplo n.º 1
0
        public bool TryCreateException(Message message, MessageFault fault, out Exception exception)
        {
            if (message == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("message");
            }
            if (fault == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("fault");
            }

            bool created = this.OnTryCreateException(message, fault, out exception);

            if (created)
            {
                if (exception == null)
                {
                    string text = SR.Format(SR.FaultConverterDidNotCreateException, this.GetType().Name);
                    Exception error = new InvalidOperationException(text);
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(error);
                }
            }
            else
            {
                if (exception != null)
                {
                    string text = SR.Format(SR.FaultConverterCreatedException, this.GetType().Name);
                    Exception error = new InvalidOperationException(text, exception);
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(error);
                }
            }

            return created;
        }
 public XmlRpcMessage(MessageFault fault)
     : this()
 {
     isFault = true;
     bodyReader = XmlRpcDataContractSerializationHelper.CreateFaultReader(fault);
     bodyReader.MoveToContent();
 }
 protected FaultException(SerializationInfo info, StreamingContext context) : base(info, context)
 {
     this.code = this.ReconstructFaultCode(info, "code");
     this.reason = this.ReconstructFaultReason(info, "reason");
     this.fault = (MessageFault) info.GetValue("messageFault", typeof(MessageFault));
     this.action = info.GetString("action");
 }
Ejemplo n.º 4
0
        private static LogData CreateLogbookentry(Exception error, MessageFault fault)
        {
            string typeName, methodName;

            string assemblyName = typeName = methodName = "Unknown";

            if (error.TargetSite != null)
            {
                assemblyName = error.TargetSite.Module.Assembly.GetName().Name;
                methodName = error.TargetSite.Name;
                if (error.TargetSite.DeclaringType != null) typeName = error.TargetSite.DeclaringType.Name;
            }

            string fileName = GetFileName(error);
            int lineNumber = GetLineNumber(error);
            string exceptionName = error.GetType().ToString();
            string exceptionMessage = error.Message;
            string providedFault = String.Empty;
            string providedMessage = String.Empty;

            if (fault != null)
            {
                providedFault = (fault.Code == null) ? "Unknown" : fault.Code.Name;

                providedMessage = (fault.Reason == null || fault.Reason.Translations == null ||
                                   fault.Reason.Translations.Count <= 0)
                                      ? "Unknown"
                                      : fault.Reason.Translations[0].Text;
            }
            return new LogData(assemblyName, fileName, lineNumber, typeName, methodName, exceptionName, exceptionMessage,
                               providedFault, providedMessage);
        }
 public bool TryCreateException(Message message, MessageFault fault, out Exception exception)
 {
     if (message == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("message");
     }
     if (fault == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("fault");
     }
     bool flag = this.OnTryCreateException(message, fault, out exception);
     if (flag)
     {
         if (exception == null)
         {
             Exception exception2 = new InvalidOperationException(System.ServiceModel.SR.GetString("FaultConverterDidNotCreateException", new object[] { base.GetType().Name }));
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(exception2);
         }
         return flag;
     }
     if (exception != null)
     {
         Exception exception3 = new InvalidOperationException(System.ServiceModel.SR.GetString("FaultConverterCreatedException", new object[] { base.GetType().Name }), exception);
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(exception3);
     }
     return flag;
 }
Ejemplo n.º 6
0
		protected override bool OnTryCreateException (
			Message message, MessageFault fault, out Exception error)
		{
			if (message == null)
				throw new ArgumentNullException ("message");
			if (fault == null)
				throw new ArgumentNullException ("fault");

			error = null;

			FaultCode fc;
			if (version.Envelope.Equals (EnvelopeVersion.Soap11))
				fc = fault.Code;
			else
				fc = fault.Code.SubCode;

			if (fc == null)
				return false;

			string msg = fault.Reason.GetMatchingTranslation ().Text;
			if (fc.Namespace == message.Version.Addressing.Namespace) {
				switch (fc.Name) {
				case "ActionNotSupported":
					error = new ActionNotSupportedException (msg);
					return true;
				case "DestinationUnreachable":
					error = new EndpointNotFoundException (msg);
					return true;
				}
			}

			return false;
		}
Ejemplo n.º 7
0
		static void AreMessageFaultEqual (MessageFault a, MessageFault b, string label)
		{
			Assert.AreEqual (a.Actor, b.Actor, label + ".Actor");
			Assert.AreEqual (a.Code, b.Code, label + ".Code");
			Assert.AreEqual (a.HasDetail, b.HasDetail, label + ".HasDetail");
			Assert.AreEqual (a.Node, b.Node, label + ".Node");
			Assert.AreEqual (a.Reason, b.Reason, label + ".Reason");
		}
Ejemplo n.º 8
0
        public SdmxMessageFault(MessageFault messageFault, string nameSpace)
        {
            if (messageFault == null)
            {
                throw new ArgumentNullException("messageFault");
            }

            this._messageFault = messageFault;
            this._nameSpace = nameSpace;
        }
 public FaultException(MessageFault fault) : base(GetSafeReasonText(GetReason(fault)))
 {
     if (fault == null)
     {
         throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("fault");
     }
     this.code = EnsureCode(fault.Code);
     this.reason = EnsureReason(fault.Reason);
     this.fault = fault;
 }
Ejemplo n.º 10
0
		public FaultException (MessageFault fault, string action)
		{
			if (fault == null)
				throw new ArgumentNullException ("fault");
			//if (action == null)
			//	throw new ArgumentNullException ("action");

			this.fault = fault;
			this.action = action;
		}
 public void Fault(Message message, MessageFault fault)
 {
     if (this.CheckMessage(message, false) != null)
     {
         this.state.Perf.FaultsReceivedCountPerInterval.Increment();
     }
     if (DebugTrace.Info)
     {
         DebugTrace.Trace(TraceLevel.Info, "Ignoring {0} fault from completion participant at {1}: {2}", Library.GetFaultCodeName(fault), Ports.TryGetFromAddress(message), Library.GetFaultCodeReason(fault));
     }
 }
 public static FaultCode GetBaseFaultCode(MessageFault fault)
 {
     FaultCode subCode = fault.Code;
     if (subCode != null)
     {
         while (subCode.SubCode != null)
         {
             subCode = subCode.SubCode;
         }
     }
     return subCode;
 }
Ejemplo n.º 13
0
 public static void LogError(Exception error,MessageFault fault)
 {
     LogbookEntryClient entry = CreateLogbookEntry(error,fault);
      try
      {
     LogbookManagerClient proxy = new LogbookManagerClient();
     proxy.LogEntry(entry);
     proxy.Close();
      }
      catch
      {}
 }
 public static void LogError(Exception error, MessageFault fault)
 {
     string message = CreateLogbookentry(error, fault).ToString();
     if (error is SemanticException)
     {
         s_Logger.Debug(message, error);
     }
     else
     {
         s_Logger.Error(message, error);
     }
 }
Ejemplo n.º 15
0
        static void Main(string[] args)
        {
            FaultCode       code        = FaultCode.CreateSenderFaultCode("calcuError", "http://www.artech.com");
            FaultReasonText reasonText1 = new FaultReasonText("Divided by zero!", "en-US");
            FaultReasonText reasonText2 = new FaultReasonText("试图除以零!", "zh-CN");
            FaultReason     reason      = new FaultReason(new FaultReasonText[] { reasonText1, reasonText2 });
            MessageFault    fault       = MessageFault.CreateFault(code, reason);
            string          action      = "http://www.artech.com/divideFault";

            using (Message message = Message.CreateMessage(MessageVersion.Default, fault, action))
            {
                WriteMessage(message, "message.xml");
            }
        }
Ejemplo n.º 16
0
        protected override FaultException CreateFaultException(MessageFault messageFault, string action)
        {
            IList <XmlSerializerOperationBehavior.Reflector.XmlSerializerFaultContractInfo> faultInfos;

            if (action != null)
            {
                faultInfos = new List <XmlSerializerOperationBehavior.Reflector.XmlSerializerFaultContractInfo>();
                for (int i = 0; i < xmlSerializerFaultContractInfos.Count; i++)
                {
                    if (xmlSerializerFaultContractInfos[i].FaultContractInfo.Action == action ||
                        xmlSerializerFaultContractInfos[i].FaultContractInfo.Action == MessageHeaders.WildcardAction)
                    {
                        faultInfos.Add(xmlSerializerFaultContractInfos[i]);
                    }
                }
            }
            else
            {
                faultInfos = xmlSerializerFaultContractInfos;
            }

            Type   detailType = null;
            object detailObj  = null;

            for (int i = 0; i < faultInfos.Count; i++)
            {
                XmlSerializerOperationBehavior.Reflector.XmlSerializerFaultContractInfo faultInfo = faultInfos[i];
                XmlDictionaryReader detailReader = messageFault.GetReaderAtDetailContents();
                XmlObjectSerializer serializer   = faultInfo.Serializer;

                if (serializer.IsStartObject(detailReader))
                {
                    detailType = faultInfo.FaultContractInfo.Detail;
                    try
                    {
                        detailObj = serializer.ReadObject(detailReader);
                        FaultException faultException = CreateFaultException(messageFault, action,
                                                                             detailObj, detailType, detailReader);
                        if (faultException != null)
                        {
                            return(faultException);
                        }
                    }
                    catch (SerializationException)
                    {
                    }
                }
            }
            return(new FaultException(messageFault, action));
        }
        public static FaultException CreateFault(MessageFault messageFault, string action, params System.Type[] faultDetailTypes)
        {
            if (messageFault == null)
            {
                throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("messageFault");
            }
            if (faultDetailTypes == null)
            {
                throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("faultDetailTypes");
            }
            DataContractSerializerFaultFormatter formatter = new DataContractSerializerFaultFormatter(faultDetailTypes);

            return(formatter.Deserialize(messageFault, action));
        }
Ejemplo n.º 18
0
        public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            if (error is FaultException)
            {
                return;
            }

            //bool serviceDebug = OperationContext.Current.EndpointDispatcher.ChannelDispatcher.IncludeExceptionDetailInFaults;

            FaultException faultException = new FaultException("The server encountered an error of type " + error.GetType());
            MessageFault   faultMessage   = faultException.CreateMessageFault();

            fault = Message.CreateMessage(version, faultMessage, faultException.Action);
        }
Ejemplo n.º 19
0
        public void CreateFaultMessageAndWrite()
        {
            string xml = @"<s:Envelope xmlns:a=""http://www.w3.org/2005/08/addressing"" xmlns:s=""http://www.w3.org/2003/05/soap-envelope""><s:Header><a:Action s:mustUnderstand=""1"">http://www.w3.org/2005/08/addressing/fault</a:Action></s:Header><s:Body><s:Fault><s:Code><s:Value xmlns:a=""urn:me"">a:me</s:Value></s:Code><s:Reason><s:Text xml:lang="""">am so lazy</s:Text></s:Reason></s:Fault></s:Body></s:Envelope>";

            FaultCode       fc  = new FaultCode("me", "urn:me");
            FaultReasonText ft  = new FaultReasonText("am so lazy", CultureInfo.InvariantCulture);
            Message         msg = Message.CreateMessage(
                MessageVersion.Default,
                MessageFault.CreateFault(fc, new FaultReason(ft)),
                "http://www.w3.org/2005/08/addressing/fault");

            // It should be XML comparison, not string comparison
            Assert.AreEqual(xml, GetSerializedMessage(msg));
        }
Ejemplo n.º 20
0
        public CoreWCF.Channels.Message Untyped_MethodReturns(CoreWCF.Channels.Message msgIn)
        {
            CoreWCF.Channels.MessageVersion mv = OperationContext.Current.IncomingMessageHeaders.MessageVersion;
            string faultToThrow = "Test fault thrown from a service";

            if (msgIn != null)
            {
                return(Message.CreateMessage(mv, MessageFault.CreateFault(new FaultCode("Sender"), new FaultReason("Unspecified ServiceModel Fault"), faultToThrow,
                                                                          new System.Runtime.Serialization.DataContractSerializer(typeof(string)), "", ""), ""));
            }

            return(Message.CreateMessage(mv, MessageFault.CreateFault(new FaultCode("Sender"), new FaultReason("Unspecified ServiceModel Fault"), "unspeficied",
                                                                      new System.Runtime.Serialization.DataContractSerializer(typeof(string)), "", ""), ""));
        }
Ejemplo n.º 21
0
    /// <summary>
    /// ProvideFault
    /// </summary>
    /// <param name="ex">ex</param>
    /// <param name="version">version</param>
    /// <param name="msg">msg</param>
    public void ProvideFault(Exception ex, MessageVersion version, ref Message msg)
    {
        //
        //在这里处理服务端的消息,将消息写入服务端的日志
        //
        string err   = string.Format("调用WCF接口 '{0}' 出错", ex.TargetSite.ReflectedType.FullName + "." + ex.TargetSite.Name) + Environment.NewLine + ex.Message;
        var    newEx = new FaultException(err);
        ILog   alog  = log4net.LogManager.GetLogger("SysRun");

        alog.Error(string.Format("调用WCF接口 '{0}' 出错", ex.TargetSite.ReflectedType.FullName + "." + ex.TargetSite.Name) + Environment.NewLine + ex.Message + Environment.NewLine + ex.StackTrace); //+ex.TargetSite.GetParameters
        MessageFault msgFault = newEx.CreateMessageFault();

        msg = Message.CreateMessage(version, msgFault, newEx.Action);
    }
Ejemplo n.º 22
0
        public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            if (error is FaultException)
            {
                return;
            }
            BusinessServiceException businessFault            = new BusinessServiceException(error);
            FaultException <BusinessServiceException> faultEx =
                new FaultException <BusinessServiceException>(businessFault, "Error occurs in business service",
                                                              new FaultCode("BusinessServiceException"));
            MessageFault msgFault = faultEx.CreateMessageFault();

            fault = Message.CreateMessage(version, msgFault, faultEx.Action);
        }
Ejemplo n.º 23
0
        public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            if (error is FaultException)
            {
                return;
            }

            FaultException faultException
                = new FaultException(error.Message, new FaultCode("InnerServiceException"));

            MessageFault msg = faultException.CreateMessageFault();

            fault = Message.CreateMessage(version, msg, "null");
        }
        /*
         * Show Message Box With SOAP Error If We Receive A Fault Code Back From Service
         *
         */
        private void LogSoapException(FaultException e)
        {
            MessageFault message          = e.CreateMessageFault();
            XmlElement   errorDetail      = message.GetDetail <XmlElement>();
            XmlNodeList  errorDetails     = errorDetail.ChildNodes;
            String       fullErrorDetails = "";

            for (int i = 0; i < errorDetails.Count; i++)
            {
                fullErrorDetails += errorDetails.Item(i).Name + ": " + errorDetails.Item(i).InnerText + "\n";
            }

            _log.Error("An Error Occured With Royal Mail Api Service: " + message.Reason.ToString() + "\n\n" + fullErrorDetails);
        }
Ejemplo n.º 25
0
            public object Invoke(object instance, object[] inputs, out object[] outputs)
            {
                FaultException exception;
                ServiceChannel serviceChannel;

                outputs = EmptyArray <object> .Allocate(0);

                Message message = inputs[0] as Message;

                if (message != null)
                {
                    string action = message.Headers.Action;
                    if (DiagnosticUtility.ShouldTraceInformation)
                    {
                        TraceUtility.TraceEvent(TraceEventType.Information, 0x80037, System.ServiceModel.SR.GetString("TraceCodeUnhandledAction"), new StringTraceRecord("Action", action), this, null, message);
                    }
                    FaultCode   code   = FaultCode.CreateSenderFaultCode("ActionNotSupported", message.Version.Addressing.Namespace);
                    FaultReason reason = new FaultReason(System.ServiceModel.SR.GetString("SFxNoEndpointMatchingContract", new object[] { action }));
                    exception = new FaultException(reason, code);
                    System.ServiceModel.Dispatcher.ErrorBehavior.ThrowAndCatch(exception);
                    serviceChannel = OperationContext.Current.InternalServiceChannel;
                    OperationContext.Current.OperationCompleted += delegate(object sender, EventArgs e) {
                        ChannelDispatcher channelDispatcher = this.dispatchRuntime.ChannelDispatcher;
                        if (!channelDispatcher.HandleError(exception) && serviceChannel.HasSession)
                        {
                            try
                            {
                                serviceChannel.Close(ChannelHandler.CloseAfterFaultTimeout);
                            }
                            catch (Exception exception1)
                            {
                                if (Fx.IsFatal(exception1))
                                {
                                    throw;
                                }
                                channelDispatcher.HandleError(exception1);
                            }
                        }
                    };
                    if (this.dispatchRuntime.shared.EnableFaults)
                    {
                        MessageFault fault = MessageFault.CreateFault(code, reason, action);
                        return(Message.CreateMessage(message.Version, fault, message.Version.Addressing.DefaultFaultAction));
                    }
                    OperationContext.Current.RequestContext.Close();
                    OperationContext.Current.RequestContext = null;
                }
                return(null);
            }
Ejemplo n.º 26
0
        /// <summary>
        /// 启用创建从服务方法过程中的异常返回的自定义 System.ServiceModel.FaultException&lt;TDetail&gt;。
        /// </summary>
        /// <param name="error"> 服务操作过程中引发的 System.Exception 对象。</param>
        /// <param name="version">消息的 SOAP 版本。</param>
        /// <param name="fault">双工情况下,返回到客户端或服务的 System.ServiceModel.Channels.Message 对象。</param>
        public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            var context = OperationContext.Current;

            if (context == null)
            {
                return;
            }
            ////获取传进的消息属性

            MessageProperties properties = context.IncomingMessageProperties;
            var endpoint = properties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
            var message  = context.RequestContext.RequestMessage;
            var action   = message.Headers.Action;
            var document = new XmlDocument();

            document.LoadXml(message.ToString());
            var nodes = document.GetElementsByTagName(action.Substring(action.LastIndexOf('/') + 1));
            var dic   = new Dictionary <string, string>();
            var dis   = IsLogDisable(context, action);

            dic.Add("url", context.Host.BaseAddresses[0].AbsolutePath + action.Substring(action.LastIndexOf('/')));
            dic.Add("host", context.Host.BaseAddresses[0].AbsoluteUri);
            var xmlNode = nodes.Item(0);

            if (xmlNode != null)
            {
                dic.Add("parameter", xmlNode.InnerXml);
            }
            dic.Add("message", error.Message);
            //int errorCode = error is ServiceException ? ((ServiceException)error).Code : 0;
            //var faultException = error is FaultException ?
            //   (FaultException)error : new FaultException<ErrorInfo>(new ErrorInfo
            //   {
            //       Message = error.Message,
            //       ErrorCode = errorCode
            //   }, error.Message);
            var faultException =
                new FaultException(error.Message);

            MessageFault messageFault = faultException.CreateMessageFault();

            fault = Message.CreateMessage(version, messageFault, action);
            Log.Write(
                string.Format("\r\n请求: {0} + !\r\n调用信息:{1}\r\n参数:{2}\r\n返回信息:{3}", dic["host"], dic["url"],
                              dic["parameter"], dic["message"]), MessageType.Error, this.GetType(), error);

            //ExceptionHelper.LogException(error, null, dic, null);
        }
Ejemplo n.º 27
0
        public async Task <string> CreateVideoAsync(IStorageFile file, Video v)
        {
            VideoSubmition videoSubmition = new VideoSubmition
            {
                Tags    = v.Tags,
                Title   = v.Title,
                Synopse = v.Synopse
            };

            Video createdVideo = null;

            try
            {
                using (EnsureCredentialsUseContext context = new EnsureCredentialsUseContext(
                           this.Username, this.Password, this.AccessKey, _client.InnerChannel))
                {
                    createdVideo = await this._client.AddVideoPostAsync(videoSubmition, null);
                }
            }
            catch (FaultException faultException)
            {
                MessageFault messageFault = faultException.CreateMessageFault();

                if (messageFault.HasDetail)
                {
                    string innerErrorXml;
                    using (var xmlReader = messageFault.GetReaderAtDetailContents())
                    {
                        innerErrorXml = xmlReader.ReadInnerXml();
                    }
                    if (innerErrorXml != null)
                    {
                        throw new Exception(innerErrorXml);
                    }
                    throw;
                }
            }

            string token = createdVideo.Token;

            BackgroundUploader uploader = new BackgroundUploader();

            UploadOperation uploadOperation =
                await VideosServiceClient.CreateUploadOperationForCreateVideo(file, token, uploader);

            await uploadOperation.StartAsync();

            return(await GetResponseMessage(uploadOperation));
        }
Ejemplo n.º 28
0
        public ActionResult Grabar(int id, string placa, string clase, string marca, string modelo,
                                   string color, int motor, int asientos, int puertas, string fecinscripcion,
                                   string anio, string estado)
        {
            try
            {
                Movilidad busAGrabar = new Movilidad()
                {
                    Id            = id,
                    Placa         = placa,
                    Clase         = clase,
                    Marca         = marca,
                    Modelo        = modelo,
                    Color         = color,
                    Motor         = motor,
                    Asientos      = asientos,
                    Puertas       = puertas,
                    FeInscripcion = DateTime.Parse(fecinscripcion),
                    Año           = anio,
                    Estado        = estado
                };

                Movilidad bus = null;
                if (busAGrabar.Id == 0)
                {
                    bus = new BusesClient().CrearMovilidad(busAGrabar);
                }
                else
                {
                    bus = new BusesClient().ModificarMovilidad(busAGrabar);
                }

                if (bus != null)
                {
                    return(Json("Success", JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json("Datos incorrectos", JsonRequestBehavior.AllowGet));
                }
            }
            catch (FaultException error)
            {
                MessageFault            fault  = error.CreateMessageFault();
                BusWS.RepetidoException detail = fault.GetDetail <BusWS.RepetidoException>();

                return(Json(detail.descripcion, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 29
0
        private static MethodFault GetVIServerFault(FaultException soapEx)
        {
            if (soapEx == null)
            {
                throw new ArgumentNullException("soapEx");
            }
            PropertyInfo property = soapEx.GetType().GetTypeInfo().GetProperty("Detail");

            VimApi_65.MethodFault methodFault;
            if (property != (PropertyInfo)null)
            {
                methodFault = property.GetValue((object)soapEx) as VimApi_65.MethodFault;
            }
            else
            {
                MessageFault  messageFault  = soapEx.CreateMessageFault();
                XmlSerializer xmlSerializer = FaultUtility.GetFaultSerializer();
                if (xmlSerializer == null)
                {
                    /* XElement xelement = (XElement)XNode.ReadFrom((XmlReader)messageFault.GetReaderAtDetailContents());
                     * System.Type type = typeof(VimApi_65.MethodFault).Assembly.GetType(string.Format("{0}.{1}", (object)typeof(VimApi_65.MethodFault).Namespace, (object)xelement.Attribute(XName.Get("type", "http://www.w3.org/2001/XMLSchema-instance")).Value));
                     * XmlRootAttribute xmlRootAttribute = new XmlRootAttribute(xelement.Name.LocalName);
                     * // ISSUE: variable of the null type
                     * __Null local1 = null;
                     * // ISSUE: variable of the null type
                     * __Null local2 = null;
                     * XmlRootAttribute root = xmlRootAttribute;
                     * string defaultNamespace = "urn:vim25";
                     * xmlSerializer = new XmlSerializer(type, (XmlAttributeOverrides)local1, (System.Type[])local2, root, defaultNamespace); */
                    XElement         xElement   = (XElement)XNode.ReadFrom(messageFault.GetReaderAtDetailContents());
                    XAttribute       xAttribute = xElement.Attribute(XName.Get("type", "http://www.w3.org/2001/XMLSchema-instance"));
                    string           name       = string.Format("{0}.{1}", typeof(VimApi_65.MethodFault).Namespace, xAttribute.Value);
                    Type             arg_D0_0   = typeof(VimApi_65.MethodFault).Assembly.GetType(name);
                    XmlRootAttribute root       = new XmlRootAttribute(xElement.Name.LocalName);
                    xmlSerializer = new XmlSerializer(arg_D0_0, null, null, root, "urn:vim25");
                }
                StringReader stringReader = new StringReader(messageFault.GetDetail <XElement>().ToString().Replace("xsd:", ""));
                using (XmlReader xmlReader = XmlReader.Create((TextReader)stringReader, new XmlReaderSettings()
                {
                    ConformanceLevel = ConformanceLevel.Fragment,
                    CloseInput = true
                }))
                {
                    int content = (int)xmlReader.MoveToContent();
                    methodFault = xmlSerializer.Deserialize(xmlReader) as VimApi_65.MethodFault;
                }
            }
            return(VIConvert.ToVim((object)methodFault) as MethodFault);
        }
Ejemplo n.º 30
0
        protected override FaultException CreateFaultException(MessageFault messageFault, string action)
        {
            IList <XmlSerializerOperationBehavior.Reflector.XmlSerializerFaultContractInfo> faultInfos;

            if (action != null)
            {
                faultInfos = new List <XmlSerializerOperationBehavior.Reflector.XmlSerializerFaultContractInfo>();
                for (int i = 0; i < _xmlSerializerFaultContractInfos.Count; i++)
                {
                    if (_xmlSerializerFaultContractInfos[i].FaultContractInfo.Action == action ||
                        _xmlSerializerFaultContractInfos[i].FaultContractInfo.Action == MessageHeaders.WildcardAction)
                    {
                        faultInfos.Add(_xmlSerializerFaultContractInfos[i]);
                    }
                }
            }
            else
            {
                faultInfos = _xmlSerializerFaultContractInfos;
            }

            for (int i = 0; i < faultInfos.Count; i++)
            {
                XmlSerializerOperationBehavior.Reflector.XmlSerializerFaultContractInfo faultInfo = faultInfos[i];
                XmlDictionaryReader detailReader = messageFault.GetReaderAtDetailContents();
                XmlObjectSerializer serializer   = faultInfo.Serializer;

                if (serializer.IsStartObject(detailReader))
                {
                    Type detailType = faultInfo.FaultContractInfo.Detail;
                    try
                    {
                        object         detailObj      = serializer.ReadObject(detailReader);
                        FaultException faultException = CreateFaultException(messageFault, action,
                                                                             detailObj, detailType, detailReader);
                        if (faultException != null)
                        {
                            return(faultException);
                        }
                    }
#pragma warning disable CA1031 // Do not catch general exception types - if we can't deserialie the message fault detail, return plain FaultException
                    catch (SerializationException)
                    {
                    }
#pragma warning restore CA1031 // Do not catch general exception types
                }
            }
            return(new FaultException(messageFault, action));
        }
Ejemplo n.º 31
0
        public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            if (error is FaultException)
            {
                return;
            }

            string errorDescription = string.Format("{0} {1} {2}", error.Message,
                                                    Environment.NewLine,
                                                    error.StackTrace);
            FaultException exception = new FaultException(errorDescription);
            MessageFault   msgFault  = exception.CreateMessageFault();

            fault = Message.CreateMessage(version, msgFault, null);
        }
Ejemplo n.º 32
0
        public void ProvideFault(Exception error,
                                 System.ServiceModel.Channels.MessageVersion version,
                                 ref System.ServiceModel.Channels.Message fault)
        {
            if (error is FaultException)
            {
                return;
            }

            // Return a general service error message to the client
            FaultException faultException = new FaultException("A general service error occured");
            MessageFault   messageFault   = faultException.CreateMessageFault();

            fault = Message.CreateMessage(version, messageFault, null);
        }
Ejemplo n.º 33
0
        /// <summary>
        /// 在异常发生后,异常信息返回前被调用
        /// </summary>
        /// <param name="error">异常</param>
        /// <param name="version">SOAP版本</param>
        /// <param name="fault">返回给客户端的错误信息</param>
        public void ProvideFault(System.Exception error, System.ServiceModel.Channels.MessageVersion version, ref System.ServiceModel.Channels.Message fault)
        {
            if (error is System.IO.IOException)
            {
                FaultException ex = new FaultException("IErrorHandler - ProvideFault测试");

                MessageFault mf = ex.CreateMessageFault();

                fault = System.ServiceModel.Channels.Message.CreateMessage(version, mf, ex.Action);

                // InvalidOperationException error = new InvalidOperationException("An invalid operation has occurred.");
                // MessageFault mfault = MessageFault.CreateFault(new FaultCode("Server", new FaultCode(String.Format("Server.{0}", error.GetType().Name))), new FaultReason(error.Message), error);
                // FaultException fe = FaultException.CreateFault(mfault, typeof(InvalidOperationException));
            }
        }
Ejemplo n.º 34
0
        public Message CreateErrorResponse(Exception excp)
        {
            FaultException fe    = new FaultException(excp.Message);
            MessageFault   fault = fe.CreateMessageFault();

            Message response = Message.CreateMessage(MessageVersion.Default, fault, null);

            HttpResponseMessageProperty http = new HttpResponseMessageProperty();

            http.StatusCode         = System.Net.HttpStatusCode.OK;
            http.SuppressEntityBody = true;
            response.Properties.Add(HttpResponseMessageProperty.Name, http);

            return(response);
        }
Ejemplo n.º 35
0
 public static FaultException ConstructFaultException(Message response)
 {
     Type[] typeArray = new Type[9];
     typeArray[0] = typeof(FragmentDialect);
     typeArray[1] = typeof(AttributeTypeNotValid);
     typeArray[2] = typeof(EnumerateFault);
     typeArray[3] = typeof(FaultDetail);
     typeArray[4] = typeof(FaultDetail1);
     typeArray[5] = typeof(SupportedSelectOrSortDialect);
     typeArray[6] = typeof(SupportedDialect);
     typeArray[7] = typeof(PullFault);
     typeArray[8] = typeof(RenewFault);
     Type[] typeArray1 = typeArray;
     return(FaultException.CreateFault(MessageFault.CreateFault(response, 0x500000), typeArray1));
 }
Ejemplo n.º 36
0
        public static FaultException CreateFault(MessageFault messageFault, string action, params Type[] faultDetailTypes)
        {
            if (messageFault == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(messageFault));
            }

            if (faultDetailTypes == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(faultDetailTypes));
            }
            DataContractSerializerFaultFormatter faultFormatter = new DataContractSerializerFaultFormatter(faultDetailTypes);

            return(faultFormatter.Deserialize(messageFault, action));
        }
Ejemplo n.º 37
0
        public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            if (error is EntityValidationException)
            {
                LoggerServiceHelper.Current.TraceException(this, error);

                MessageFault messageFault = MessageFault.CreateFault(
                    new FaultCode("Sender"),
                    new FaultReason(error.Message),
                    error,
                    new NetDataContractSerializer());

                fault = Message.CreateMessage(version, messageFault, null);
            }
        }
Ejemplo n.º 38
0
        public void ShouldGetFaultExceptionWithoutPolicy()
        {
            ExceptionShieldingErrorHandler shielding = new ExceptionShieldingErrorHandler();
            FaultException faultException            = GetFaultException("test", SoapException.ServerFaultCode.Name);
            Message        message = Message.CreateMessage(MessageVersion.Default, faultException.CreateMessageFault(), "");

            shielding.ProvideFault(faultException, MessageVersion.Default, ref message);

            MessageFault actualFault   = GetFaultFromMessage(message);
            MessageFault expectedFault = faultException.CreateMessageFault();

            Assert.AreEqual(expectedFault.Reason.ToString(), actualFault.Reason.ToString());
            Assert.AreEqual(expectedFault.HasDetail, actualFault.HasDetail);
            Assert.AreEqual(expectedFault.Code.IsReceiverFault, actualFault.Code.IsReceiverFault);
        }
Ejemplo n.º 39
0
        /// <summary>
        /// Put the request item into the storage. and the storage will cache the requests in the memory
        /// until the front end call the flush method. the async result will return the BrokerQueueItem.
        /// </summary>
        /// <param name="context">the request context relate to the message</param>
        /// <param name="msg">the request message</param>
        /// <param name="asyncState">the asyncState relate to the message</param>
        public override async Task PutRequestAsync(Telepathy.ServiceBroker.FrontEnd.RequestContextBase context, Message msg, object asyncState)
        {
            this.queue.Enqueue(new BrokerQueueItem(context, msg, asyncState));
            if (this.directReply)
            {
                MessageFault fault = MessageFault.CreateFault(FaultCode.CreateReceiverFaultCode("DummyReply", "http://hpc.microsoft.com"), "DummyReply");
                Message      reply = Message.CreateMessage(context.MessageVersion, fault, msg.Headers.Action + "Response");
                if (context.MessageVersion == MessageVersion.Default)
                {
                    reply.Headers.RelatesTo = msg.Headers.MessageId;
                }

                context.Reply(reply, TimeSpan.MaxValue);
            }
        }
 /// <summary>
 /// Processa a respota recebida.
 /// </summary>
 /// <param name="reply"></param>
 /// <param name="correlationState"></param>
 public void AfterReceiveReply(ref System.ServiceModel.Channels.Message reply, object correlationState)
 {
     if (reply.IsFault)
     {
         var buffer = reply.CreateBufferedCopy(Int32.MaxValue);
         var copy   = buffer.CreateMessage();
         reply = buffer.CreateMessage();
         var messageFault = MessageFault.CreateFault(copy, 0x10000);
         if ((messageFault.Code.Name == InvalidTokenFaultReasonCode || messageFault.Code.Name == EmptyTokenFaultReasonCode) && messageFault.Code.Namespace == Namespace)
         {
             throw new InvalidSecurityTokenException(messageFault.Reason.ToString(), FaultException.CreateFault(messageFault));
         }
         throw FaultException.CreateFault(messageFault);
     }
 }
 protected override bool OnTryCreateException(Message message, MessageFault fault, out Exception exception)
 {
     if (this.innerChannel == null)
     {
         exception = null;
         return false;
     }
     FaultConverter property = this.innerChannel.GetProperty<FaultConverter>();
     if (property != null)
     {
         return property.TryCreateException(message, fault, out exception);
     }
     exception = null;
     return false;
 }
Ejemplo n.º 42
0
        public void ShouldReturnReceiverFault()
        {
            ExceptionShieldingErrorHandler shielding = new ExceptionShieldingErrorHandler("CustomPolicy");
            Message   message   = GetDefaultMessage();
            Exception exception = new NotSupportedException("NotSupportedException");

            shielding.ProvideFault(exception, MessageVersion.Default, ref message);

            MessageFault fault = GetFaultFromMessage(message);

            Assert.IsTrue(fault.Code.IsReceiverFault);
            Assert.IsFalse(string.IsNullOrEmpty(fault.Reason.ToString()));
            Assert.IsFalse(fault.HasDetail);
            CheckHandlingInstanceId("DefaultLogs.txt", fault.Reason.ToString());
        }
Ejemplo n.º 43
0
        /// <summary>
        /// 将Exception转化为FaultException
        /// </summary>
        /// <param name="error">Exception</param>
        /// <param name="version">MessageVersion</param>
        /// <param name="fault">错误消息</param>
        public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            if (error is FaultException)
            {
                return;
            }

            FaultCodeAttribute attribute = error.GetType().GetCustomAttribute <FaultCodeAttribute>();
            var faultCode = attribute == null?error.GetType().Name : attribute.Name;

            FaultException faultException = new FaultException(error.Message, new FaultCode(faultCode));
            MessageFault   messageFault   = faultException.CreateMessageFault();

            fault = Message.CreateMessage(version, messageFault, faultException.Action);
        }
Ejemplo n.º 44
0
        private void OnReceive(ref Message reply)
        {
            if (reply.IsFault && reply.Headers.Action == FaultMessage.FaultAction)
            {
                var fault = MessageFault.CreateFault(reply, int.MaxValue);
                if (fault.Code.SubCode.Name == FaultMessage.FaultSubCodeName &&
                    fault.Code.SubCode.Namespace == FaultMessage.FaultSubCodeNamespace)
                {
                    var exception = (FaultException <FaultMessage>)FaultException
                                    .CreateFault(fault, typeof(FaultMessage));

                    throw GetException(exception.Detail);
                }
            }
        }
 private void HandleFault(FaultContractWrapperException faultContractWrapper, ref Message fault)
 {
     try
     {
         MessageFault messageFault = BuildMessageFault(faultContractWrapper);
         fault = Message.CreateMessage(fault.Version, messageFault, GetFaultAction(faultContractWrapper) ?? fault.Headers.Action);
     }
     catch (Exception unhandledException)
     {
         // There was an error during MessageFault build process, so treat it as an Unhandled Exception
         // log the exception and send an unhandled server exception
         Guid handlingInstanceId = ExceptionUtility.LogServerException(unhandledException);
         HandleFault(unhandledException, ref fault, handlingInstanceId, null);
     }
 }
        protected override FaultException CreateFaultException(MessageFault messageFault, string action)
        {
            IList<XmlSerializerOperationBehavior.Reflector.XmlSerializerFaultContractInfo> faultInfos;
            if (action != null)
            {
                faultInfos = new List<XmlSerializerOperationBehavior.Reflector.XmlSerializerFaultContractInfo>();
                for (int i = 0; i < _xmlSerializerFaultContractInfos.Count; i++)
                {
                    if (_xmlSerializerFaultContractInfos[i].FaultContractInfo.Action == action
                        || _xmlSerializerFaultContractInfos[i].FaultContractInfo.Action == MessageHeaders.WildcardAction)
                    {
                        faultInfos.Add(_xmlSerializerFaultContractInfos[i]);
                    }
                }
            }
            else
            {
                faultInfos = _xmlSerializerFaultContractInfos;
            }

            Type detailType = null;
            object detailObj = null;
            for (int i = 0; i < faultInfos.Count; i++)
            {
                XmlSerializerOperationBehavior.Reflector.XmlSerializerFaultContractInfo faultInfo = faultInfos[i];
                XmlDictionaryReader detailReader = messageFault.GetReaderAtDetailContents();
                XmlObjectSerializer serializer = faultInfo.Serializer;

                if (serializer.IsStartObject(detailReader))
                {
                    detailType = faultInfo.FaultContractInfo.Detail;
                    try
                    {
                        detailObj = serializer.ReadObject(detailReader);
                        FaultException faultException = CreateFaultException(messageFault, action,
                            detailObj, detailType, detailReader);
                        if (faultException != null)
                            return faultException;
                    }
                    catch (SerializationException)
                    {
                    }
                }
            }
            return new FaultException(messageFault, action);
        }
 public static string GetFaultCodeName(MessageFault fault)
 {
     FaultCode subCode = fault.Code;
     if (subCode == null)
     {
         return "unknown";
     }
     if (subCode.SubCode != null)
     {
         subCode = subCode.SubCode;
         if (subCode == null)
         {
             return "unknown";
         }
     }
     return subCode.Name;
 }
 protected override FaultException CreateFaultException(MessageFault messageFault, string action)
 {
     IList<XmlSerializerOperationBehavior.Reflector.XmlSerializerFaultContractInfo> xmlSerializerFaultContractInfos;
     if (action != null)
     {
         xmlSerializerFaultContractInfos = new List<XmlSerializerOperationBehavior.Reflector.XmlSerializerFaultContractInfo>();
         for (int j = 0; j < this.xmlSerializerFaultContractInfos.Count; j++)
         {
             if ((this.xmlSerializerFaultContractInfos[j].FaultContractInfo.Action == action) || (this.xmlSerializerFaultContractInfos[j].FaultContractInfo.Action == "*"))
             {
                 xmlSerializerFaultContractInfos.Add(this.xmlSerializerFaultContractInfos[j]);
             }
         }
     }
     else
     {
         xmlSerializerFaultContractInfos = this.xmlSerializerFaultContractInfos;
     }
     System.Type detailType = null;
     object detailObj = null;
     for (int i = 0; i < xmlSerializerFaultContractInfos.Count; i++)
     {
         XmlSerializerOperationBehavior.Reflector.XmlSerializerFaultContractInfo info = xmlSerializerFaultContractInfos[i];
         XmlDictionaryReader readerAtDetailContents = messageFault.GetReaderAtDetailContents();
         XmlObjectSerializer serializer = info.Serializer;
         if (serializer.IsStartObject(readerAtDetailContents))
         {
             detailType = info.FaultContractInfo.Detail;
             try
             {
                 detailObj = serializer.ReadObject(readerAtDetailContents);
                 FaultException exception = base.CreateFaultException(messageFault, action, detailObj, detailType, readerAtDetailContents);
                 if (exception != null)
                 {
                     return exception;
                 }
             }
             catch (SerializationException)
             {
             }
         }
     }
     return new FaultException(messageFault, action);
 }
        protected override bool OnTryCreateException(Message message, MessageFault fault, out Exception exception)
        {
            if (_innerChannel == null)
            {
                exception = null;
                return false;
            }

            FaultConverter inner = _innerChannel.GetProperty<FaultConverter>();
            if (inner != null)
            {
                return inner.TryCreateException(message, fault, out exception);
            }
            else
            {
                exception = null;
                return false;
            }
        }
 public static string GetFaultCodeReason(MessageFault fault)
 {
     FaultReasonText matchingTranslation;
     FaultReason reason = fault.Reason;
     if (reason == null)
     {
         return "unknown";
     }
     try
     {
         matchingTranslation = reason.GetMatchingTranslation(CultureInfo.CurrentCulture);
     }
     catch (ArgumentException exception)
     {
         Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Warning);
         return "unknown";
     }
     return matchingTranslation.Text;
 }
 public static CoordinatorRegistrationFailedFault CreateFault(MessageFault fault)
 {
     string str;
     if (fault == null)
     {
         str = Microsoft.Transactions.SR.GetString("CoordinatorRegistrationFailedReason");
     }
     else
     {
         string faultCodeName = Library.GetFaultCodeName(fault);
         if (faultCodeName == null)
         {
             str = Microsoft.Transactions.SR.GetString("CoordinatorRegistrationFaultedUnknownReason");
         }
         else
         {
             str = Microsoft.Transactions.SR.GetString("CoordinatorRegistrationFaultedReason", new object[] { faultCodeName });
         }
     }
     return new CoordinatorRegistrationFailedFault(str);
 }
        private static ExceptionLogbookEntry CreateLogbookentry(Exception error, MessageFault fault)
        {
            string typeName;
            string methodName;

            string assemblyName = typeName = methodName = "Unknown";

            try
            {
                if (error.TargetSite != null)
                {
                    assemblyName = error.TargetSite.Module.Assembly.GetName().Name;
                    methodName = error.TargetSite.Name;
                    if (error.TargetSite.DeclaringType != null)
                    {
                        typeName = error.TargetSite.DeclaringType.Name;
                    }
                }
            }
            catch (Exception)
            {
                assemblyName = "Could not reflect assembly name.";
            }

            string fileName = GetFileName(error);
            int lineNumber = GetLineNumber(error);
            string exceptionName = error.GetType().ToString();
            string exceptionMessage = error.Message;
            string providedFault = string.Empty;
            string providedMessage = string.Empty;

            if (fault != null)
            {
                providedFault = fault.Code.Name;
                providedMessage = fault.Reason.Translations[0].Text;
            }

            return new ExceptionLogbookEntry(assemblyName, fileName, lineNumber, typeName, methodName, exceptionName, exceptionMessage, providedFault, providedMessage);
        }
Ejemplo n.º 53
0
        public FaultException(MessageFault fault)
            : base(FaultException.GetSafeReasonText(GetReason(fault)))
        {
            if (fault == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("fault");

            this.code = FaultException.EnsureCode(fault.Code);
            this.reason = FaultException.EnsureReason(fault.Reason);
            this.fault = fault;
        }
Ejemplo n.º 54
0
        internal static string GetSafeReasonText(MessageFault messageFault)
        {
            if (messageFault == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("messageFault");

            return GetSafeReasonText(messageFault.Reason);
        }
Ejemplo n.º 55
0
#pragma warning restore 688

        static FaultReason GetReason(MessageFault fault)
        {
            if (fault == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("fault");
            }
            return fault.Reason;
        }
Ejemplo n.º 56
0
        public static FaultException CreateFault(MessageFault messageFault, string action, params Type[] faultDetailTypes)
        {
            if (messageFault == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("messageFault");
            }

            if (faultDetailTypes == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("faultDetailTypes");
            }
            DataContractSerializerFaultFormatter faultFormatter = new DataContractSerializerFaultFormatter(faultDetailTypes);
            return faultFormatter.Deserialize(messageFault, action);
        }
Ejemplo n.º 57
0
 public static FaultException CreateFault(MessageFault messageFault, params Type[] faultDetailTypes)
 {
     return CreateFault(messageFault, null, faultDetailTypes);
 }
Ejemplo n.º 58
0
        public FaultException(MessageFault fault, string action)
            : base(FaultException.GetSafeReasonText(GetReason(fault)))
        {
            if (fault == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("fault");

            this.code = fault.Code;
            this.reason = fault.Reason;
            this.fault = fault;
            this.action = action;
        }
Ejemplo n.º 59
0
        public static bool TryCreateFault12(ReliableMessagingVersion reliableMessagingVersion, Message message,
            MessageFault fault, out WsrmHeaderFault wsrmFault)
        {
            // All wsrm header faults must be sender or receiver faults.
            if (!fault.Code.IsSenderFault && !fault.Code.IsReceiverFault)
            {
                wsrmFault = null;
                return false;
            }

            if ((fault.Code.SubCode == null)
                || (fault.Code.SubCode.Namespace != WsrmIndex.GetNamespaceString(reliableMessagingVersion)) || !fault.HasDetail)
            {
                wsrmFault = null;
                return false;
            }

            string subcodeName = fault.Code.SubCode.Name;
            XmlDictionaryReader detailReader = fault.GetReaderAtDetailContents();
            wsrmFault = CreateWsrmHeaderFault(reliableMessagingVersion, fault.Code, subcodeName, fault.Reason,
                detailReader);

            return (wsrmFault != null);
        }
Ejemplo n.º 60
0
        public static bool TryCreateFault11(ReliableMessagingVersion reliableMessagingVersion, Message message,
            MessageFault fault, int index, out WsrmHeaderFault wsrmFault)
        {
            if (index == -1)
            {
                wsrmFault = null;
                return false;
            }

            // All wsrm header faults must be sender or receiver faults.
            if (!fault.Code.IsSenderFault && !fault.Code.IsReceiverFault)
            {
                wsrmFault = null;
                return false;
            }

            string subcodeName = WsrmSequenceFaultHeader.GetSubcode(message.Headers.GetReaderAtHeader(index),
                reliableMessagingVersion);

            if (subcodeName == null)
            {
                wsrmFault = null;
                return false;
            }

            string detailName;
            string detailNamespace;

            LookupDetailInformation(reliableMessagingVersion, subcodeName, out detailName, out detailNamespace);

            XmlDictionaryReader detailReader = WsrmSequenceFaultHeader.GetReaderAtDetailContents(detailName,
                detailNamespace, message.Headers.GetReaderAtHeader(index), reliableMessagingVersion);

            if (detailReader == null)
            {
                wsrmFault = null;
                return false;
            }

            wsrmFault = CreateWsrmHeaderFault(reliableMessagingVersion, fault.Code, subcodeName, fault.Reason,
                detailReader);
            if (wsrmFault != null)
            {
                message.Headers.UnderstoodHeaders.Add(message.Headers[index]);
                return true;
            }
            else
            {
                return false;
            }
        }