コード例 #1
0
        public SoapException GetFault(EndpointVersionType endpointVersion, Exception ex)
        {
            LOG.Error(ex.Message, ex);

            ENExceptionCodeType code = ENExceptionCodeType.E_Unknown;

            if (!string.IsNullOrEmpty(ex.HelpLink))
            {
                try
                {
                    code = (ENExceptionCodeType)Enum.Parse(typeof(ENExceptionCodeType), ex.HelpLink, true);
                }
                catch (Exception enumEx)
                {
                    LOG.Error("Invalid eror code: " + ex.HelpLink, enumEx);
                }
            }

            return(GetFault(endpointVersion, code, CleanseExceptionMessage(ex)));
        }
コード例 #2
0
        public SoapException GetFault(EndpointVersionType endpointVersion, ENExceptionCodeType code, string descr)
        {
            if (string.IsNullOrEmpty(descr))
            {
                descr = _defaultErrorDescription;
            }

            string detailName, detailNamespaceUri, errorCodeName, faultName, namespaceUri;

            if (endpointVersion == EndpointVersionType.EN20)
            {
                detailName         = "soap:Detail";
                detailNamespaceUri = "http://www.w3.org/2003/05/soap-envelope";
                errorCodeName      = "errorCode";
                faultName          = "NodeFaultDetailType";
                namespaceUri       = "http://www.exchangenetwork.net/schema/node/2";
            }
            else
            {
                detailName    = SoapException.DetailElementName.Name;
                errorCodeName = "errorcode";
                faultName     = "faultdetail";
                namespaceUri  = detailNamespaceUri = string.Empty;
            }

            XmlDocument doc  = new XmlDocument();
            XmlNode     node = doc.CreateNode(
                XmlNodeType.Element,
                detailName,
                detailNamespaceUri);

            System.Xml.XmlNode details = doc.CreateNode(
                XmlNodeType.Element,
                faultName,
                namespaceUri);

            System.Xml.XmlNode errorCode = doc.CreateNode(
                XmlNodeType.Element,
                errorCodeName,
                namespaceUri);

            errorCode.InnerText = code.ToString();
            details.AppendChild(errorCode);

            System.Xml.XmlNode desc = doc.CreateNode(
                XmlNodeType.Element,
                "description",
                namespaceUri);

            desc.InnerText = descr;
            details.AppendChild(desc);

            // Append the two child elements to the detail node.
            node.AppendChild(details);

            string errorUri = null;

            if (System.Web.HttpContext.Current != null &&
                System.Web.HttpContext.Current.Request != null)
            {
                errorUri = System.Web.HttpContext.Current.Request.RawUrl.ToString();
            }

            //Throw the exception.

            SoapException soapException =
                new SoapException(descr, SoapException.ServerFaultCode, errorUri, node);

            soapException.HelpLink = code.ToString();
            return(soapException);
        }
コード例 #3
0
 public SoapException GetFault(EndpointVersionType endpointVersion, ENExceptionCodeType code, string format, params object[] args)
 {
     return(GetFault(endpointVersion, code, string.Format(format, args)));
 }