Exemplo n.º 1
0
        private static string GenerateErrorMessage(SessionFault sessionFault, string defaultMessage)
        {
            string message = SR.ResourceManager.GetString(SOAFaultCode.GetFaultCodeName(sessionFault.Code), CultureInfo.CurrentCulture);

            if (message != null)
            {
                if (sessionFault.Context == null || sessionFault.Context.Length == 0)
                {
                    return(message);
                }
                else
                {
                    object[] objArr = new object[sessionFault.Context.Length];
                    for (int i = 0; i < objArr.Length; i++)
                    {
                        objArr[i] = sessionFault.Context[i];
                    }

                    return(String.Format(CultureInfo.CurrentCulture, message, objArr));
                }
            }
            else
            {
                return(defaultMessage);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Generates the fault message from fault code
        /// </summary>
        /// <param name="requestMessage">indicating the request message</param>
        /// <param name="version">message version</param>
        /// <param name="code">indicating the soa fault code</param>
        /// <param name="reason">indicating the reason</param>
        /// <param name="context">indicating the context</param>
        /// <returns>fault message</returns>
        public static Message GenerateFaultMessage(Message requestMessage, MessageVersion version, int code, string reason, params string[] context)
        {
            string errorMessage = context == null || context.Length == 0 ? reason : String.Format(CultureInfo.CurrentCulture, reason, context);
            FaultException <SessionFault> faultException = new FaultException <SessionFault>(new SessionFault(code, reason, context), errorMessage, FaultCode.CreateReceiverFaultCode(SOAFaultCode.GetFaultCodeName(code), Constant.HpcHeaderNS), SessionFault.Action);

            return(GenerateFaultMessage(requestMessage, version, faultException));
        }