Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
3.5 KiB

  1. using System;
  2. using System.IO;
  3. using System.Xml.Serialization;
  4. using System.Web.Services.Protocols;
  5. using Microsoft.Uddi.VersionSupport;
  6. namespace Microsoft.Uddi
  7. {
  8. public class UddiException : ApplicationException
  9. {
  10. private DispositionReport dispositionReport;
  11. private bool hasDispositionReportData;
  12. private static XmlSerializer serializer = null;
  13. public enum ErrorType
  14. {
  15. E_success = 0,
  16. E_nameTooLong = 10020,
  17. E_tooManyOptions = 10030,
  18. E_unrecognizedVersion = 10040,
  19. E_unsupported = 10050,
  20. E_languageError = 10060,
  21. E_authTokenExpired = 10110,
  22. E_authTokenRequired = 10120,
  23. E_operatorMismatch = 10130,
  24. E_userMismatch = 10140,
  25. E_unknownUser = 10150,
  26. E_accountLimitExceeded = 10160,
  27. E_invalidKeyPassed = 10210,
  28. E_invalidURLPassed = 10220,
  29. E_keyRetired = 10310,
  30. E_busy = 10400,
  31. E_fatalError = 10500,
  32. E_invalidCategory = 20000,
  33. E_categorizationNotAllowed = 20100
  34. }
  35. public UddiException( string message ) : base( message )
  36. {
  37. dispositionReport = null;
  38. hasDispositionReportData = false;
  39. }
  40. public UddiException( Exception exception ) : base( "", exception )
  41. {
  42. dispositionReport = null;
  43. hasDispositionReportData = false;
  44. }
  45. public UddiException( SoapException soapException ) : base( "", soapException )
  46. {
  47. dispositionReport = null;
  48. hasDispositionReportData = false;
  49. //
  50. // The soap exception passed in SHOULD contain a disposition report.
  51. // Deserialize it into an object and use the error number in this exception
  52. //
  53. if( false == Utility.StringEmpty( soapException.Detail.InnerXml ) )
  54. {
  55. //
  56. // Translate the XML into the current version.
  57. //
  58. string dispositionReportXml = UddiVersionSupport.Translate( soapException.Detail.InnerXml, UddiVersionSupport.CurrentVersion );
  59. StringReader reader = new StringReader( dispositionReportXml );
  60. if( null == serializer )
  61. {
  62. serializer = new XmlSerializer( typeof( DispositionReport ) );
  63. }
  64. dispositionReport = ( DispositionReport ) serializer.Deserialize( reader );
  65. reader.Close();
  66. }
  67. hasDispositionReportData = ( null != dispositionReport )&&
  68. ( null != dispositionReport.Results ) &&
  69. ( dispositionReport.Results.Count > 0 );
  70. }
  71. //
  72. // This property makes what we expect to be a commonly used piece of information more visible.
  73. //
  74. public ErrorType Type
  75. {
  76. get
  77. {
  78. if( true == hasDispositionReportData )
  79. {
  80. //
  81. // Only return the first result, this is the most common case. The use can access the
  82. // full DispositionReport object if they are interested in the full results.
  83. //
  84. return ( ErrorType )dispositionReport.Results[0].Errno;
  85. }
  86. else
  87. {
  88. return ErrorType.E_fatalError;
  89. }
  90. }
  91. }
  92. public override string Message
  93. {
  94. get
  95. {
  96. if( true == hasDispositionReportData )
  97. {
  98. //
  99. // Only return the first result, this is the most common case. The use can access the
  100. // full DispositionReport object if they are interested in the full results.
  101. //
  102. return dispositionReport.Results[0].ErrInfo.Text;
  103. }
  104. else
  105. {
  106. return InnerException.Message;
  107. }
  108. }
  109. }
  110. public DispositionReport DispositionReport
  111. {
  112. get { return dispositionReport; }
  113. }
  114. }
  115. }