/*******************************************************/ //Assembly References for this project: //Microsoft.ServiceModel.Channels.dll (WCF LOB Adapter SDK) //System.ServiceModel.dll //System.Configuration.dll //Sign this "Class Library" dll with a strong name, and add it to the GAC. //Register the binding extension in machine.config: // // // // // // // //To use this from BizTalk (using the WCF Adapter): //(a)In the receive location configuration, select the Behaviors tab //(b)click on Endpoint Behavior, then right click and choose "Add Extension" //(c)Add the myInboundAction extension //(d)Set the ReceiveActions and Delimiter property. If you want to add multiple actions, concatenate them //in the ReceiveActions property, and set the Delimiter appropriately. /*******************************************************/ using System; using System.Collections.Generic; using System.Text; using System.ServiceModel.Description; using System.ServiceModel.Configuration; using Microsoft.ServiceModel.Channels; using System.Configuration; using System.ComponentModel; public sealed class MyInboundActionEndpointBehavior : IEndpointBehavior { public readonly List mActions = new List(); public void AddBindingParameters(ServiceEndpoint endpoint, System.ServiceModel.Channels.BindingParameterCollection bindingParameters) { if (bindingParameters == null) return; if (endpoint == null || endpoint.Address == null) return; //InboundActionCollection is an ASDK class. This class is the one which //maps to the actions in StartListener. InboundActionCollection actions = new InboundActionCollection(endpoint.Address.Uri); actions.AddRange(mActions); bindingParameters.Add(actions); } public void ApplyClientBehavior(ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.ClientRuntime clientRuntime) { } public void ApplyDispatchBehavior(ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.EndpointDispatcher endpointDispatcher) { } public void Validate(ServiceEndpoint endpoint) { } } public sealed class MyInboundActionElement : BehaviorExtensionElement { public override Type BehaviorType { get { return typeof(MyInboundActionEndpointBehavior); } } protected override object CreateBehavior() { MyInboundActionEndpointBehavior behavior = new MyInboundActionEndpointBehavior(); String receiveActions = (string)base["receiveActions"]; String delimiter = (string)base["delimiter"]; if (!String.IsNullOrEmpty(receiveActions)) { if (!String.IsNullOrEmpty(delimiter)) { String[] actionArray = receiveActions.Split(new string[] { delimiter }, StringSplitOptions.RemoveEmptyEntries); behavior.mActions.AddRange(actionArray); } else { behavior.mActions.Add(receiveActions); } } return behavior; } protected override System.Configuration.ConfigurationPropertyCollection Properties { get { ConfigurationPropertyCollection properties = base.Properties; properties.Add(new ConfigurationProperty("receiveActions", typeof(string))); properties.Add(new ConfigurationProperty("delimiter", typeof(string))); return properties; } } [Browsable(true)] [ConfigurationProperty("receiveActions")] public string ReceiveActions { get { string val = (string)base["receiveActions"]; return val; } set { base["receiveActions"] = value; } } [Browsable(true)] [ConfigurationProperty("delimiter")] public string Delimiter { get { string val = (string)base["delimiter"]; return val; } set { base["delimiter"] = value; } } public override void CopyFrom(ServiceModelExtensionElement from) { base.CopyFrom(from); MyInboundActionElement element = from as MyInboundActionElement; this.ReceiveActions = element.ReceiveActions; this.Delimiter = element.Delimiter; } }