WCF – Issue a request over https with custom header

In my current project I need to call a web service over https. Security is implemented by using a custom header (old school). To support this in WCF follow the following simple steps:

In the configuration file (app.config) make the following changes:

<client>
    <endpoint address=”https://…
        binding="basicHttpBinding" bindingConfiguration="MyHttpsBinding"
        contract="…" name="ACC">
        <headers>     <!—your custom header here  –>
            <credentials >
                <username>…</username>
                <password>…</password>
            </credentials>
        </headers>
    </endpoint>
</client>

Add a new binding:

<binding name="MyHttpsBinding">
    <security mode="Transport">
        <transport>
            <extendedProtectionPolicy policyEnforcement="Never" />
        </transport>
    </security>
</binding>

Advertisement

About Gaston

MCT, MCSD, MCDBA, MCSE, MS Specialist
This entry was posted in Development. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s