3 // Copyright (c) Microsoft Corporation. All rights reserved.
6 /*============================================================
10 ** <EMAIL>Author: Peter de Jong (Microsoft)</EMAIL>
12 ** Purpose: Specifies information for a Soap Fault
14 ** Date: June 27, 2000
16 ===========================================================*/
17 #if FEATURE_REMOTING || MOBILE_LEGACY
18 namespace System.Runtime.Serialization.Formatters
21 using System.Runtime.Serialization;
22 using System.Runtime.Remoting;
23 using System.Runtime.Remoting.Metadata;
24 using System.Globalization;
25 using System.Security.Permissions;
27 //* Class holds soap fault information
30 [SoapType(Embedded=true)]
31 [System.Runtime.InteropServices.ComVisible(true)]
32 public sealed class SoapFault : ISerializable
37 [SoapField(Embedded=true)] Object detail;
43 public SoapFault(String faultCode, String faultString, String faultActor, ServerFault serverFault)
45 this.faultCode = faultCode;
46 this.faultString = faultString;
47 this.faultActor = faultActor;
48 this.detail = serverFault;
51 internal SoapFault(SerializationInfo info, StreamingContext context)
53 SerializationInfoEnumerator siEnum = info.GetEnumerator();
55 while(siEnum.MoveNext())
57 String name = siEnum.Name;
58 Object value = siEnum.Value;
59 SerTrace.Log(this, "SetObjectData enum ",name," value ",value);
60 if (String.Compare(name, "faultCode", true, CultureInfo.InvariantCulture) == 0)
62 int index = ((String)value).IndexOf(':');
64 faultCode = ((String)value).Substring(++index);
66 faultCode = (String)value;
68 else if (String.Compare(name, "faultString", true, CultureInfo.InvariantCulture) == 0)
69 faultString = (String)value;
70 else if (String.Compare(name, "faultActor", true, CultureInfo.InvariantCulture) == 0)
71 faultActor = (String)value;
72 else if (String.Compare(name, "detail", true, CultureInfo.InvariantCulture) == 0)
77 [System.Security.SecurityCritical] // auto-generated_required
78 public void GetObjectData(SerializationInfo info, StreamingContext context)
80 info.AddValue("faultcode", "SOAP-ENV:"+faultCode);
81 info.AddValue("faultstring", faultString);
82 if (faultActor != null)
83 info.AddValue("faultactor", faultActor);
84 info.AddValue("detail", detail, typeof(Object));
87 public String FaultCode
89 get {return faultCode;}
90 set { faultCode = value;}
93 public String FaultString
95 get {return faultString;}
96 set { faultString = value;}
100 public String FaultActor
102 get {return faultActor;}
103 set { faultActor = value;}
110 set {detail = value;}
115 [SoapType(Embedded=true)]
116 [System.Runtime.InteropServices.ComVisible(true)]
117 public sealed class ServerFault
119 String exceptionType;
124 internal ServerFault(Exception exception)
126 this.exception = exception;
127 //this.exceptionType = exception.GetType().AssemblyQualifiedName;
128 //this.message = exception.Message;
131 public ServerFault(String exceptionType, String message, String stackTrace)
133 this.exceptionType = exceptionType;
134 this.message = message;
135 this.stackTrace = stackTrace;
139 public String ExceptionType
141 get {return exceptionType;}
142 set { exceptionType = value;}
145 public String ExceptionMessage
147 get {return message;}
148 set { message = value;}
152 public String StackTrace
154 get {return stackTrace;}
155 set {stackTrace = value;}
158 internal Exception Exception
160 get {return exception;}
164 #endif // FEATURE_REMOTING