1

I'm trying to implement my own version of the Custom Behavior shown here: Using Windows Credentials in WCF-Custom adapter and here: Impersonate WCF Credentials when calling a WCF Service

BizTalk requires everything to be put in the GAC, which I did by running GacUtil.

I attempted the following changes to machine.config, and I know they didn't work because if I restart the BizTalk Host Instance, I get bizarre errors.

Changed from this:

  <section name="extensions" type="System.ServiceModel.Configuration.ExtensionsSection, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>

To this:

  <section name="extensions" type="System.ServiceModel.Configuration.ExtensionsSection, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <add name="WindowsCredentialsBehaviour" type="MyApp.Biztalk.WCF.Extensions.ImpersonateBasicCredentialsBehaviour, MyApp.CustomEndpointBehavior, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b12735283a466be4" />
  </section>

In BizTalk, the Assembly looks like this:

MyApp.CustomEndpointBehavior, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b12735283a466be4"

So I have two main questions:

  1. I'm not sure why in the config file there are two names, is one the class or behavior name, and the second is the assembly name?
  2. What did I do wrong?

Here are my namespaces:

namespace MyApp.Biztalk.WCF.Extensions
{
    public class ImpersonateBasicCredentialsBehaviour : IEndpointBehavior
...
namespace MyApp.Biztalk.WCF.Extensions
{
    public class ImpersonateBasicCredentialsBehaviourElement : BehaviorExtensionElement
...

I also tried to edit machine.config with the SDK tool: SvcConfigEditor.exe, but it gave this error, so I was left to edit in NotePad++.

enter image description here

Dijkgraaf
  • 11,049
  • 17
  • 42
  • 54
NealWalters
  • 17,197
  • 42
  • 141
  • 251

1 Answers1

1

You don't need to define your section (it's already defined). Instead, you just configure your extension in the machine level configuration:

<system.serviceModel>
    <extensions>
        <behaviorExtensions>
            <add name="WindowsCredentialsBehaviour" type="MyApp.Biztalk.WCF.Extensions.ImpersonateBasicCredentialsBehaviour, Asurion.CustomEndpointBehavior" />
        </behaviorExtensions>
    </extensions>
</system.serviceModel>

It will then merge with any application's configuration file that utilizes WCF (system.serviceModel). You just need to make sure the type MyApp.Biztalk.WCF.Extensions.ImpersonateBasicCredentialsBehaviour is in the assembly available to an application that wants to use WCF (either in GAC or in a private bin path).

UserControl
  • 14,766
  • 20
  • 100
  • 187
  • Ah, ok! I was on the path of a new feature in BT2010: http://www.codit.eu/blog/2012/12/14/how-to-register-wcf-extensions-in-biztalk/ which lets me pull it into BizTalk a different way as well. – NealWalters Jul 14 '15 at 21:41