none
Runtime Endpoint Behavior RRS feed

  • Question

  • I'm using 2006 R2 and I have an orchestration as a WCF service.

     

    We have internal endpoint behavior extensions that need applying which dictate whether the message information is stored and some security access information.

     

    We also have a binding extension which extends the standard WsHttpBinding and adds policy information.

     

    I've added both the binding extension and the behavior extension to the machine.config so BizTalk can see them.

     

    I've  chosen the WCF-CustomIsolated adapter, chosen my binding extension and added my Endpoint behavior extension. This is all fine.

     

    However currently my binding extension does not do anything with the behavior but I need to get at the behavior and export the information in the policies. The problem I have is how to get the behavior back so I can check it's properties.

    If it was nice standard WCF I'd probably read through the web.config for some of the information, but I've found that the information in the config file doesn't seem readily available or even applicable to a BizTalk "WCF" service.

     

    Is there a way at runtime from within a binding extension or policy exporter (I have the PolicyContext) or getting the Endpoint back so I can loop through the behaviors to get at my extension?

     

    I assumed there would be something in Microsoft.BizTalk.Adapter.Wcf.Runtime namespace, but I can't find anything.

     

    Thx,

    CD

    Thursday, October 4, 2007 5:00 PM

Answers

  • There is an indirect way to access your endpoint behavior within a binding element.

    You can pass the reference of the behavior using the BindingParameterCollection to the context of the channel stack.

     

     

    Lets say that you've the following custom endpoint behavior. Note that the reference of the behavior is added to the bindingParameters.

     

    public class MyCustomEndpointBehavior : IEndpointBehavior

    {

    public int a;

    public void AddBindingParameters(ServiceEndpoint endpoint, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)

    {

    a = 5;

    bindingParameters.Add(this);

    }

    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)

    {

    }

    }

     

    then, you can have a custom binding element that can access your behavior in BuildChannelListener method.

     

     

    public override IChannelListener<TChannel> BuildChannelListener<TChannel>(BindingContext context)

    {

    MyCustomEndpointBehavior myBehavior = ((MyCustomEndpointBehavior)context.BindingParameters[1]); //just used the index for demonstration purposes.

    ....

    }

     

    Hope this helps.

     

    -Karahan

    Thursday, October 18, 2007 12:28 AM

All replies

  • Well an Endpoint has a behaviors collection, as well as a Service Host.

     

    I suspect that your problem here is that niether the Endpoint nor the Service Host is available to you becuase you're using WCF Adapters on the Receive Side, which dynamically creates the Service Host and Endpoints based off the Channel stack configuration you provide through the WCF Adapters... Am I Correct?

     

    As I'm typing this, I don't have VS.NET pulled up in front of me, however, I'll take a guess here that you should be able to get to the Service Host or Endpoint using an InstanceContext within a Behavior that you've attached to the WCF Custom Isolated Adapter. 

     

    HTH

     

    Tuesday, October 16, 2007 2:05 PM
  • There is an indirect way to access your endpoint behavior within a binding element.

    You can pass the reference of the behavior using the BindingParameterCollection to the context of the channel stack.

     

     

    Lets say that you've the following custom endpoint behavior. Note that the reference of the behavior is added to the bindingParameters.

     

    public class MyCustomEndpointBehavior : IEndpointBehavior

    {

    public int a;

    public void AddBindingParameters(ServiceEndpoint endpoint, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)

    {

    a = 5;

    bindingParameters.Add(this);

    }

    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)

    {

    }

    }

     

    then, you can have a custom binding element that can access your behavior in BuildChannelListener method.

     

     

    public override IChannelListener<TChannel> BuildChannelListener<TChannel>(BindingContext context)

    {

    MyCustomEndpointBehavior myBehavior = ((MyCustomEndpointBehavior)context.BindingParameters[1]); //just used the index for demonstration purposes.

    ....

    }

     

    Hope this helps.

     

    -Karahan

    Thursday, October 18, 2007 12:28 AM