public Transaction UnmarshalTransaction(WsatTransactionInfo info)
        {
            if (info.Context.ProtocolVersion != this.protocolVersion)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(System.ServiceModel.SR.GetString("InvalidWsatProtocolVersion")));
            }
            if (this.wsatConfig.OleTxUpgradeEnabled)
            {
                byte[] propagationToken = info.Context.PropagationToken;
                if (propagationToken != null)
                {
                    try
                    {
                        return(OleTxTransactionInfo.UnmarshalPropagationToken(propagationToken));
                    }
                    catch (TransactionException exception)
                    {
                        DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Warning);
                    }
                    if (DiagnosticUtility.ShouldTraceInformation)
                    {
                        TraceUtility.TraceEvent(TraceEventType.Information, 0xe000e, System.ServiceModel.SR.GetString("TraceCodeTxFailedToNegotiateOleTx", new object[] { info.Context.Identifier }));
                    }
                }
            }
            CoordinationContext context = info.Context;

            if (!this.wsatConfig.IsLocalRegistrationService(context.RegistrationService, this.protocolVersion))
            {
                if (!this.wsatConfig.IsProtocolServiceEnabled(this.protocolVersion))
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new TransactionException(System.ServiceModel.SR.GetString("WsatProtocolServiceDisabled", new object[] { this.protocolVersion })));
                }
                if (!this.wsatConfig.InboundEnabled)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new TransactionException(System.ServiceModel.SR.GetString("InboundTransactionsDisabled")));
                }
                if (this.wsatConfig.IsDisabledRegistrationService(context.RegistrationService))
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new TransactionException(System.ServiceModel.SR.GetString("SourceTransactionsDisabled")));
                }
                context = this.CreateCoordinationContext(info);
            }
            Guid localTransactionId = context.LocalTransactionId;

            if (localTransactionId == Guid.Empty)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new TransactionException(System.ServiceModel.SR.GetString("InvalidCoordinationContextTransactionId")));
            }
            return(OleTxTransactionInfo.UnmarshalPropagationToken(MarshalPropagationToken(ref localTransactionId, context.IsolationLevel, context.IsolationFlags, context.Description)));
        }
Пример #2
0
        public Transaction UnmarshalTransaction(WsatTransactionInfo info)
        {
            if (info.Context.ProtocolVersion != this.protocolVersion)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                          new ArgumentException(SR.GetString(SR.InvalidWsatProtocolVersion)));
            }

            if (wsatConfig.OleTxUpgradeEnabled)
            {
                byte[] propToken = info.Context.PropagationToken;
                if (propToken != null)
                {
                    try
                    {
                        return(OleTxTransactionInfo.UnmarshalPropagationToken(propToken));
                    }
                    catch (TransactionException e)
                    {
                        DiagnosticUtility.TraceHandledException(e, TraceEventType.Warning);
                    }

                    // Fall back to WS-AT unmarshal
                    if (DiagnosticUtility.ShouldTraceInformation)
                    {
                        TraceUtility.TraceEvent(TraceEventType.Information,
                                                TraceCode.TxFailedToNegotiateOleTx,
                                                SR.GetString(SR.TraceCodeTxFailedToNegotiateOleTx, info.Context.Identifier));
                    }
                }
            }

            // Optimization: if the context's registration service points to our local TM, we can
            // skip the CreateCoordinationContext step
            CoordinationContext localContext = info.Context;

            if (!this.wsatConfig.IsLocalRegistrationService(localContext.RegistrationService, this.protocolVersion))
            {
                // Our WS-AT protocol service for the context's protocol version should be enabled
                if (!this.wsatConfig.IsProtocolServiceEnabled(this.protocolVersion))
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                              new TransactionException(SR.GetString(SR.WsatProtocolServiceDisabled, this.protocolVersion)));
                }

                // We should have enabled inbound transactions
                if (!this.wsatConfig.InboundEnabled)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                              new TransactionException(SR.GetString(SR.InboundTransactionsDisabled)));
                }

                // The sender should have enabled both WS-AT and outbound transactions
                if (this.wsatConfig.IsDisabledRegistrationService(localContext.RegistrationService))
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                              new TransactionException(SR.GetString(SR.SourceTransactionsDisabled)));
                }

                // Ask the WS-AT protocol service to unmarshal the transaction
                localContext = CreateCoordinationContext(info);
            }

            Guid transactionId = localContext.LocalTransactionId;

            if (transactionId == Guid.Empty)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                          new TransactionException(SR.GetString(SR.InvalidCoordinationContextTransactionId)));
            }

            byte[] propagationToken = MarshalPropagationToken(ref transactionId,
                                                              localContext.IsolationLevel,
                                                              localContext.IsolationFlags,
                                                              localContext.Description);

            return(OleTxTransactionInfo.UnmarshalPropagationToken(propagationToken));
        }