Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / TransactionBridge / Microsoft / Transactions / Wsat / Messaging / ActivationProxy.cs / 1 / ActivationProxy.cs
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
// Define the interfaces and infrastructure needed to send activation messages
using System;
using System.ServiceModel.Channels;
using System.Diagnostics;
using System.IdentityModel.Claims;
using System.IdentityModel.Policy;
using System.ServiceModel;
using System.Transactions;
using Microsoft.Transactions.Wsat.Protocol;
namespace Microsoft.Transactions.Wsat.Messaging
{
abstract class ActivationProxy : RequestReplyProxy
{
public ActivationProxy(CoordinationService coordination, EndpointAddress to)
:
base (coordination, to)
{
}
CreateCoordinationContextMessage CreateCreateCoordinationContextMessage(ref CreateCoordinationContext create)
{
CreateCoordinationContextMessage message = new CreateCoordinationContextMessage(this.messageVersion, ref create);
if (create.IssuedToken != null)
{
CoordinationServiceSecurity.AddIssuedToken(message, create.IssuedToken);
}
return message;
}
public CreateCoordinationContextResponse SendCreateCoordinationContext (ref CreateCoordinationContext create)
{
if (DebugTrace.Verbose)
{
DebugTrace.Trace(TraceLevel.Verbose, "Sending CreateCoordinationContext to {0}", this.to.Uri);
}
Message message = CreateCreateCoordinationContextMessage(ref create);
Message reply = SendRequest(message, this.coordinationStrings.CreateCoordinationContextResponseAction);
using (reply)
{
if (DebugTrace.Verbose)
{
DebugTrace.Trace(TraceLevel.Verbose, "Dispatching CreateCoordinationContextResponse reply");
if (DebugTrace.Pii)
DebugTrace.TracePii(TraceLevel.Verbose,
"Sender is {0}",
CoordinationServiceSecurity.GetSenderName(reply));
}
return new CreateCoordinationContextResponse(reply, this.protocolVersion);
}
}
public IAsyncResult BeginSendCreateCoordinationContext (ref CreateCoordinationContext create, AsyncCallback callback, object state)
{
if (DebugTrace.Verbose)
{
DebugTrace.Trace(TraceLevel.Verbose, "Sending CreateCoordinationContext to {0}", this.to.Uri);
}
Message message = CreateCreateCoordinationContextMessage(ref create);
return BeginSendRequest (message, callback, state);
}
public CreateCoordinationContextResponse EndSendCreateCoordinationContext (IAsyncResult ar)
{
try
{
Message reply = EndSendRequest(ar, this.coordinationStrings.CreateCoordinationContextResponseAction);
using (reply)
{
if (DebugTrace.Verbose)
{
DebugTrace.Trace(TraceLevel.Verbose, "Dispatching CreateCoordinationContextResponse reply");
if (DebugTrace.Pii)
DebugTrace.TracePii(TraceLevel.Verbose,
"Sender is {0}",
CoordinationServiceSecurity.GetSenderName(reply));
}
return new CreateCoordinationContextResponse(reply, this.protocolVersion);
}
}
catch (CommunicationException e)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new WsatReceiveFailureException(e));
}
}
public static void SendCreateCoordinationContextResponse (RequestAsyncResult result, ref CreateCoordinationContextResponse response)
{
Message message = new CreateCoordinationContextResponseMessage(result.MessageVersion, ref response);
if (response.IssuedToken != null)
{
CoordinationServiceSecurity.AddIssuedToken(message, response.IssuedToken);
}
result.Finished (message);
}
public static void SendFaultResponse (RequestAsyncResult result, Fault fault)
{
Library.SendFaultResponse(result, fault);
}
}
class InteropActivationProxy : ActivationProxy
{
public InteropActivationProxy(CoordinationService coordination, EndpointAddress to)
:
base (coordination, to)
{
}
protected override IChannelFactory SelectChannelFactory(out MessageVersion messageVersion)
{
this.interoperating = true;
messageVersion = this.coordinationService.InteropActivationBinding.MessageVersion;
return this.coordinationService.InteropActivationChannelFactory;
}
}
class WindowsActivationProxy : ActivationProxy
{
public WindowsActivationProxy(CoordinationService coordination, EndpointAddress to)
:
base(coordination, to)
{
}
protected override IChannelFactory SelectChannelFactory(out MessageVersion messageVersion)
{
this.interoperating = false;
EndpointIdentity identity = this.to.Identity;
if (identity != null)
{
string claimType = identity.IdentityClaim.ClaimType;
if (claimType != ClaimTypes.Spn && claimType != ClaimTypes.Upn)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
new CreateChannelFailureException(SR.GetString(SR.InvalidTrustIdentityType, claimType)));
}
}
string scheme = this.to.Uri.Scheme;
if (string.Compare(scheme,
Uri.UriSchemeNetPipe,
StringComparison.OrdinalIgnoreCase) == 0)
{
messageVersion = this.coordinationService.NamedPipeActivationBinding.MessageVersion;
return this.coordinationService.NamedPipeActivationChannelFactory;
}
else if (this.coordinationService.Config.RemoteClientsEnabled &&
string.Compare(scheme,
Uri.UriSchemeHttps,
StringComparison.OrdinalIgnoreCase) == 0)
{
messageVersion = this.coordinationService.WindowsActivationBinding.MessageVersion;
return this.coordinationService.WindowsActivationChannelFactory;
}
else
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
new CreateChannelFailureException(SR.GetString(SR.InvalidSchemeWithTrustIdentity, scheme)));
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- HtmlWindowCollection.cs
- ProfileSection.cs
- TextParentUndoUnit.cs
- StylusEditingBehavior.cs
- CodeNamespaceImport.cs
- LowerCaseStringConverter.cs
- HtmlWindow.cs
- RowBinding.cs
- PerfCounters.cs
- SerializationHelper.cs
- GridLengthConverter.cs
- ExpandCollapseProviderWrapper.cs
- SqlParameter.cs
- ThrowHelper.cs
- OleDbCommand.cs
- CatalogZoneBase.cs
- DataGridViewRowPrePaintEventArgs.cs
- AssemblyUtil.cs
- BitmapEffectrendercontext.cs
- Bits.cs
- IgnoreSectionHandler.cs
- TextBounds.cs
- AnnotationResourceChangedEventArgs.cs
- HighlightComponent.cs
- DataGridViewComboBoxEditingControl.cs
- ImageIndexConverter.cs
- DataPagerField.cs
- GeneralTransformGroup.cs
- ClientSponsor.cs
- CancellationHandler.cs
- Attributes.cs
- HwndSource.cs
- UInt64.cs
- ZipIOLocalFileDataDescriptor.cs
- PersonalizationStateInfo.cs
- PropertyCollection.cs
- TreeNodeSelectionProcessor.cs
- COM2Properties.cs
- CompensateDesigner.cs
- ExecutionContext.cs
- GridViewColumn.cs
- LoginCancelEventArgs.cs
- WebPartZoneBase.cs
- TypeBuilderInstantiation.cs
- InvokeMemberBinder.cs
- TemplateControlParser.cs
- WebServiceClientProxyGenerator.cs
- linebase.cs
- IteratorFilter.cs
- DiscoveryDocument.cs
- MailDefinitionBodyFileNameEditor.cs
- _Win32.cs
- URI.cs
- FrameworkElement.cs
- ForeignConstraint.cs
- StorageRoot.cs
- MultiBinding.cs
- ConfigurationManager.cs
- PrinterResolution.cs
- PropertyValueUIItem.cs
- PerformanceCounterLib.cs
- configsystem.cs
- _AutoWebProxyScriptWrapper.cs
- UpdatePanelControlTrigger.cs
- FontSizeConverter.cs
- ExpressionNode.cs
- CacheHelper.cs
- BindingMemberInfo.cs
- RelatedPropertyManager.cs
- SchemaNotation.cs
- BitHelper.cs
- OutgoingWebRequestContext.cs
- CompositeControlDesigner.cs
- Constraint.cs
- ResourceType.cs
- BStrWrapper.cs
- UnitySerializationHolder.cs
- GroupQuery.cs
- RoutedUICommand.cs
- SqlFlattener.cs
- CustomCategoryAttribute.cs
- ArgumentException.cs
- XPathAncestorQuery.cs
- IdentityHolder.cs
- RemoteWebConfigurationHostServer.cs
- Composition.cs
- VScrollBar.cs
- FilterUserControlBase.cs
- FontFamily.cs
- BinaryFormatter.cs
- SqlParameter.cs
- DataFieldCollectionEditor.cs
- BitmapDecoder.cs
- EntityDataSourceContextCreatedEventArgs.cs
- SqlConnectionStringBuilder.cs
- TemplateGroupCollection.cs
- SequentialOutput.cs
- LoaderAllocator.cs
- ResourceReferenceExpression.cs
- SelectionEditor.cs