コード例 #1
0
        private static void CallWCFService <ExceptionT>(Action serviceCall, string epAddress, Action <ExceptionT> faultHandler, VersionInformation serverVersion) where ExceptionT : FaultException
        {
            string serviceURI = epAddress;

            if (serverVersion != null)
            {
                serviceURI = string.Format("{0} {1} ({2})", epAddress, serverVersion.ComputerName, serverVersion.ToString());
            }
            try
            {
                serviceCall();
            }
            catch (TimeoutException ex)
            {
                throw new TimeoutErrorTransientException(serviceURI, CommonUtils.FullExceptionMessage(ex), ex);
            }
            catch (ExceptionT exceptionT)
            {
                ExceptionT obj = (ExceptionT)((object)exceptionT);
                faultHandler(obj);
            }
            catch (EndpointNotFoundException ex2)
            {
                throw new EndpointNotFoundTransientException(serviceURI, CommonUtils.FullExceptionMessage(ex2), ex2);
            }
            catch (CommunicationException ex3)
            {
                if (ex3 is FaultException)
                {
                    FaultException ex4 = (FaultException)ex3;
                    if (ex4.Code != null && ex4.Code.SubCode != null && ex4.Code.IsSenderFault && ex4.Code.SubCode.Name == "DeserializationFailed")
                    {
                        throw new CommunicationErrorPermanentException(serviceURI, CommonUtils.FullExceptionMessage(ex3), ex3);
                    }
                }
                throw new CommunicationErrorTransientException(serviceURI, CommonUtils.FullExceptionMessage(ex3), ex3);
            }
            catch (InvalidOperationException ex5)
            {
                throw new InvalidOperationTransientException(serviceURI, CommonUtils.FullExceptionMessage(ex5), ex5);
            }
            catch (InvalidDataException ex6)
            {
                throw new InvalidDataTransientException(serviceURI, CommonUtils.FullExceptionMessage(ex6), ex6);
            }
        }
コード例 #2
0
 void IMailboxReplicationService.ExchangeVersionInformation(VersionInformation clientVersion, out VersionInformation serverVersion)
 {
     serverVersion      = VersionInformation.MRS;
     this.clientVersion = clientVersion;
     this.ForwardKnownExceptions(delegate
     {
         if (clientVersion.ProductMajor < VersionInformation.MRS.ProductMajor)
         {
             throw new DownlevelClientsNotSupportedPermanentException();
         }
         if (!clientVersion[0])
         {
             MrsTracer.Service.Error("Talking to downlevel client: no Archive support", new object[0]);
             throw new UnsupportedClientVersionPermanentException(clientVersion.ComputerName, clientVersion.ToString(), "Archives");
         }
     }, null);
 }