2010-03-26 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Fri, 26 Mar 2010 08:46:06 +0000 (08:46 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Fri, 26 Mar 2010 08:46:06 +0000 (08:46 -0000)
* ClientRuntimeChannel.cs : use FaultConverter as documented at:
  http://msdn.microsoft.com/en-us/library/ms789039%28VS.100%29.aspx
  (Though I found _no_ use of this FC class in the world...)

svn path=/trunk/mcs/; revision=154251

mcs/class/System.ServiceModel/System.ServiceModel/ChangeLog
mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs

index 29493bb39c8019bfb014719531e950e5614c5dbb..b15246240f84860a471a348ffa73d073ed17f3bd 100755 (executable)
@@ -1,3 +1,9 @@
+2010-03-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientRuntimeChannel.cs : use FaultConverter as documented at:
+         http://msdn.microsoft.com/en-us/library/ms789039%28VS.100%29.aspx
+         (Though I found _no_ use of this FC class in the world...)
+
 2010-03-24  Atsushi Enomoto  <atsushi@ximian.com>
 
        * ServiceHostBase.cs : if there is an existing ChannelDispatcher
index a77327aa9b7640dd81c38f77723f58cf48d65465..de504f94e167229d105daf0d271b98190877e274 100644 (file)
@@ -482,20 +482,24 @@ namespace System.ServiceModel.MonoInternal
 
                        Message res = Request (req, OperationTimeout);
                        if (res.IsFault) {
-                               MessageFault fault = MessageFault.CreateFault (res, runtime.MaxFaultSize);
-                               if (fault.HasDetail && fault is MessageFault.SimpleMessageFault) {
-                                       MessageFault.SimpleMessageFault simpleFault = fault as MessageFault.SimpleMessageFault;
-                                       object detail = simpleFault.Detail;
-                                       Type t = detail.GetType ();
-                                       Type faultType = typeof (FaultException<>).MakeGenericType (t);
-                                       object [] constructorParams = new object [] { detail, fault.Reason, fault.Code, fault.Actor };
-                                       FaultException fe = (FaultException) Activator.CreateInstance (faultType, constructorParams);
-                                       throw fe;
-                               }
-                               else {
-                                       // given a MessageFault, it is hard to figure out the type of the embedded detail
-                                       throw new FaultException(fault);
+                               var resb = res.CreateBufferedCopy (0x10000); // FIXME: use correct MaxBufferSize
+                               MessageFault fault = MessageFault.CreateFault (resb.CreateMessage (), runtime.MaxFaultSize);
+                               var conv = OperationChannel.GetProperty<FaultConverter> () ?? FaultConverter.GetDefaultFaultConverter (res.Version);
+                               Exception ex;
+                               if (!conv.TryCreateException (resb.CreateMessage (), fault, out ex)) {
+                                       if (fault.HasDetail && fault is MessageFault.SimpleMessageFault) {
+                                               MessageFault.SimpleMessageFault simpleFault = fault as MessageFault.SimpleMessageFault;
+                                               object detail = simpleFault.Detail;
+                                               Type t = detail.GetType ();
+                                               Type faultType = typeof (FaultException<>).MakeGenericType (t);
+                                               object [] constructorParams = new object [] { detail, fault.Reason, fault.Code, fault.Actor };
+                                               ex = (FaultException) Activator.CreateInstance (faultType, constructorParams);
+                                       } else {
+                                               // given a MessageFault, it is hard to figure out the type of the embedded detail
+                                               ex = new FaultException(fault);
+                                       }
                                }
+                               throw ex;
                        }
 
                        for (int i = 0; i < inspections.Length; i++)