locked
imperative to declarative binding translation RRS feed

  • Question

  • Many of the WCF samples use imperative service bindings instead of declarative service bindings.   I would like to use declarative bindings when possible.   I was hoping that the VStudio 2008 WCF Svc Config editor could translate from declarative to imperative or vice versa but guess thats a pipe dream. 

    I am looking at the following Microsoft WCF sample and it has imperative binding code that I was hoping to translate to declarative.

    C:\Microsoft Code Samples\WCFWFCardSpace\WCF\Extensibility\Security\CustomToken\CS

    wcf samples


    Specifically, there is a BindingHelper class that has the following imperative binding code:

    public static class BindingHelper  
        {  
            public static Binding CreateCreditCardBinding()  
            {  
                HttpTransportBindingElement httpTransport = new HttpTransportBindingElement();  
     
                // the message security binding element will be configured to require a credit card  
                // token that is encrypted with the service's certificate   
                SymmetricSecurityBindingElement messageSecurity = new SymmetricSecurityBindingElement();  
                messageSecurity.EndpointSupportingTokenParameters.SignedEncrypted.Add(new CreditCardTokenParameters());  
                X509SecurityTokenParameters x509ProtectionParameters = new X509SecurityTokenParameters();  
                x509ProtectionParameters.InclusionMode = SecurityTokenInclusionMode.Never;  
                messageSecurity.ProtectionTokenParameters = x509ProtectionParameters;  
                return new CustomBinding(messageSecurity, httpTransport);  
            }  
        } 

    How would this look in a declarative binding?


    thanks!
    Sunday, January 18, 2009 1:58 AM

Answers

  • Another option would be to define a custom binding and then instruct in the configuration file to use this binding. There is still coding (the binding code) but you can expose to configuration what you need and you have a good seperation of concerns (you can omit the code above from your main logic).
    http://webservices20.blogspot.com/
    WCF Security, Performance And Testing Blog
    Sunday, January 18, 2009 1:51 PM

All replies

  • AFAIK it is not possible to use declerative binding for this: Supporting tokens and customized x509 protection are not available from configuration.
    http://webservices20.blogspot.com/
    WCF Security, Performance And Testing Blog
    Sunday, January 18, 2009 4:13 AM
  • Another option would be to define a custom binding and then instruct in the configuration file to use this binding. There is still coding (the binding code) but you can expose to configuration what you need and you have a good seperation of concerns (you can omit the code above from your main logic).
    http://webservices20.blogspot.com/
    WCF Security, Performance And Testing Blog
    Sunday, January 18, 2009 1:51 PM