예제 #1
0
        /// <summary>
        /// Parses a soap fault into an ApiException.
        /// </summary>
        /// <param name="soapex">The <see cref="SoapException"/>.</param>
        /// <returns>The <see cref="ApiException"/>.</returns>
        static public ApiException FromSoapException(SoapException soapex)
        {
            ErrorType errorType = new ErrorType();
            XmlNode   details   = soapex.Detail;

            XPathExpression expr;
            XPathNavigator  nav = details.CreateNavigator();

            System.Xml.XmlNamespaceManager nsmgr = new System.Xml.XmlNamespaceManager(details.OwnerDocument.NameTable);
            //nsmgr.AddNamespace("pfx", "urn:ebay:apis:eBLBaseComponents");

            expr = nav.Compile("/FaultDetail");
            expr.SetContext(nsmgr);

            XmlNode faultdet = XmlUtility.GetChildNode(nav, expr);

            if (faultdet != null)
            {
                nav = faultdet.CreateNavigator();
                errorType.ShortMessage = soapex.Message.Trim();

                expr = nav.Compile("Severity");
                expr.SetContext(nsmgr);

                if (XmlUtility.GetString(nav, expr).Trim() == "Warning")
                {
                    errorType.SeverityCode = SeverityCodeType.Warning;
                }
                else
                {
                    errorType.SeverityCode = SeverityCodeType.Error;
                }

                expr = nav.Compile("DetailedMessage");
                expr.SetContext(nsmgr);
                errorType.LongMessage = XmlUtility.GetString(nav, expr).Trim();

                expr = nav.Compile("ErrorCode");
                expr.SetContext(nsmgr);
                errorType.ErrorCode = XmlUtility.GetString(nav, expr).Trim();
            }
            else
            {
                errorType.SeverityCode = SeverityCodeType.Error;
                errorType.ShortMessage = soapex.Code.Name.Trim();
                errorType.LongMessage  = soapex.Message.Trim();
                errorType.ErrorCode    = "0";
            }

            ErrorTypeCollection etc = new ErrorTypeCollection();

            etc.Add(errorType);

            return(new ApiException(etc));
        }
예제 #2
0
        private static String EvaluateErrorMessages(ErrorTypeCollection errors)
        {
            String errMsg = String.Empty;

            foreach (ErrorType err in errors)
            {
                errMsg += " / " + err.LongMessage;
            }

            return(errMsg);
        }
예제 #3
0
		/// <summary>
		/// Construct an ApiException from the specified API error set (ErrorTypeCollection).
		/// </summary>
		/// <param name="errors">The errors for this exception of type <see cref="ErrorTypeCollection"/>.</param>
		public ApiException(ErrorTypeCollection errors)
		{
			mErrors = errors;
		}
예제 #4
0
		/// <summary>
		/// Parses a soap fault into an ApiException.
		/// </summary>
		/// <param name="soapex">The <see cref="SoapException"/>.</param>
		/// <returns>The <see cref="ApiException"/>.</returns>
		static public ApiException FromSoapException(SoapException soapex)
		{
			ErrorType errorType = new ErrorType();
			XmlNode details = soapex.Detail;

			XPathExpression expr;
			XPathNavigator nav = details.CreateNavigator();
			System.Xml.XmlNamespaceManager nsmgr = new System.Xml.XmlNamespaceManager(details.OwnerDocument.NameTable);
			//nsmgr.AddNamespace("pfx", "urn:ebay:apis:eBLBaseComponents");

			expr = nav.Compile("/FaultDetail");
			expr.SetContext(nsmgr);

			XmlNode faultdet = XmlUtility.GetChildNode(nav, expr);

			if (faultdet != null)
			{
				nav = faultdet.CreateNavigator();
				errorType.ShortMessage  = soapex.Message.Trim();

				expr = nav.Compile("Severity");
				expr.SetContext(nsmgr);

				if (XmlUtility.GetString(nav, expr).Trim() == "Warning")
					errorType.SeverityCode = SeverityCodeType.Warning;
				else 
					errorType.SeverityCode = SeverityCodeType.Error;

				expr = nav.Compile("DetailedMessage");
				expr.SetContext(nsmgr);
				errorType.LongMessage = XmlUtility.GetString(nav, expr).Trim();

				expr = nav.Compile("ErrorCode");
				expr.SetContext(nsmgr);
				errorType.ErrorCode = XmlUtility.GetString(nav, expr).Trim();
			} 
			else
			{
				errorType.SeverityCode = SeverityCodeType.Error;
				errorType.ShortMessage  = soapex.Code.Name.Trim();
				errorType.LongMessage = soapex.Message.Trim();
				errorType.ErrorCode = "0";

			}
			
			ErrorTypeCollection etc = new ErrorTypeCollection();
			etc.Add(errorType);
		
			return new ApiException(etc);

		}
예제 #5
0
 /// <summary>
 /// Deserialize an ApiException from serialized state information.
 /// </summary>
 /// <param name="info">The object that holds the serialized object data.</param>
 /// <param name="context">The contextual information about the source or destination.</param>
 protected ApiException(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     mErrors = (ErrorTypeCollection) info.GetValue("mErrors", typeof(ErrorTypeCollection));
 }
예제 #6
0
 /// <summary>
 /// Construct an ApiException from the specified API error set (ErrorTypeCollection).
 /// </summary>
 /// <param name="errors">The errors for this exception of type <see cref="ErrorTypeCollection"/>.</param>
 public ApiException(ErrorTypeCollection errors)
 {
     mErrors = errors;
 }