Not able to combine <enablewebscript> and <clientcredentials> in a single wcf endpoint behavior

33 views Asked by At

I am trying to combine enablewebscript and clientcredentials in a single wcf endpoint behavior so that I can fetch a x509 certificate via thumbprint. But when I define both the above mentioned tags in a single endpoint behavior, the service is not working as expected.

Is there any way to combine enablewebscript and clientcredentials in a single wcf endpoint behavior?

<behaviors>
    <endpointBehaviors>
        <behavior name="CombinedBehavior">
            <enableWebScript />
            <clientCredentials>
                <!-- Configure your client credentials settings -->
            </clientCredentials>
        </behavior>
    </endpointBehaviors>
</behaviors>

This is not working for me.

1

There are 1 answers

0
Jiayao On

As far as I know, <enableWebScript> enables the endpoint behavior that makes it possible to consume the service from ASP.NET AJAX web pages.

To call a WCF service from an ASP.NET AJAX client, the service must be configured with the WebHttpBinding and the WebScriptEnablingBehavior must be added to the endpoint behavior collection. This can be done in configuration by adding the WebScriptEnablingElement in service-side like below:

<system.serviceModel>  
<services>  
        <service name="Microsoft.Ajax.Samples.CalculatorService">  
            <endpoint address=""  
                behaviorConfiguration="AspNetAjaxBehavior"   
                binding="webHttpBinding"  
                contract="Microsoft.Ajax.Samples.ICalculator" />  
        </service>  
    </services>  
    <behaviors>  
        <endpointBehaviors>  
            <behavior name="AspNetAjaxBehavior">  
                <enableWebScript />  
            </behavior>  
        </endpointBehaviors>  
    </behaviors>  
</system.serviceModel> 

So you can't combine <enableWebScript> and <Clientcredentials> together.

More details could be found in this docs: https://learn.microsoft.com/en-us/dotnet/api/system.servicemodel.configuration.webscriptenablingelement?view=netframework-4.8.1