123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- using System;
- using System.Web.Services.Protocols;
- using System.Xml;
- using System.Text;
- namespace SamplesCommon
- {
-
-
-
- public class ExceptionHelper
- {
- private SoapException _exception = null;
-
-
-
-
- public ExceptionHelper( SoapException ex )
- {
- _exception = ex;
- }
-
-
-
- public string Message
- {
- get
- {
- return _exception.Message;
- }
- }
-
-
-
- public string Severity
- {
- get
- {
- XmlNode severityNode = _exception.Detail.SelectSingleNode( "//severity" );
- if (severityNode != null)
- {
- return severityNode.InnerText;
- }
- return "";
- }
- }
-
-
-
- public string ErrorCode
- {
- get
- {
- XmlNode errorNode = _exception.Detail.SelectSingleNode( "//errorCode" );
- if (errorNode != null)
- {
- return errorNode.InnerText;
- }
- return "";
- }
- }
-
-
-
- public string[] Details {
- get {
- XmlNodeList nodes = _exception.Detail.SelectNodes( "//messageString" );
- string[] retval = new string[nodes.Count];
- for( int idx = 0; idx < nodes.Count; idx++ ) {
- retval[idx] = nodes[idx].InnerText;
- }
- return retval;
- }
- }
-
-
-
-
- public override string ToString() {
- StringBuilder str = new StringBuilder();
-
- str.AppendFormat( "Message: {0}\n", Message );
- str.AppendFormat( "Severity: {0}\n", Severity );
- str.AppendFormat( "ErrorCode: {0}\n", ErrorCode );
- str.AppendFormat( "Details:\n" );
- foreach( string s in Details ) {
- str.AppendFormat( "\t{0}\n", s );
- }
- return str.ToString();
- }
-
-
-
-
-
-
-
-
- static public string ConvertToString( SoapException ex ) {
- ExceptionHelper exception = new ExceptionHelper( ex );
- return exception.ToString();
- }
- }
- }
|