locked
Constructing a Binding from default protocol mappings RRS feed

  • Question

  • How do I create a Binding by specifying the scheme?

    I am setting up endpoints in code and want to use any defaults that have been specified in protocolMapping sections. Is there a Factory style method that, taking a uri or scheme, generates a Binding object based on the default binding configuration?

     

    • Edited by PeteGoo Sunday, March 21, 2010 10:41 PM Clarification
    Sunday, March 21, 2010 10:40 PM

Answers

  • You cannot use the protocol mapping for explicitly defined endpoints. The protocol mapping was designed only for default endpoints. That is by design.

     

    • Marked as answer by PeteGoo Wednesday, March 24, 2010 1:08 AM
    Tuesday, March 23, 2010 10:40 PM
    Moderator

All replies

  • The protocolMapping section is only used when you do not specify any endpoints to your service. If you are configuring endpoints to your service in code then the protocolMapping section does not get used.

     

    Monday, March 22, 2010 6:01 AM
    Moderator
  • Sure, but how do I get a binding which conforms to the default protocolMapping binding from within code?
    Monday, March 22, 2010 10:08 PM
  • First, is there any reason why you are writing your endpoints in code? You should not define endpoints neither in config nor in code. You should leverage the default endpoints that the host will provide to your service whenever possible. Those default endpoints will have a binding instance to the binding type mapping the service base address scheme.

    If you explicitly define service endpoints, either in code or in config, then you will not be able to use the protocolMapping table.

     

    Tuesday, March 23, 2010 5:11 AM
    Moderator
  • Thanks for your reply.

    I have a custom WorkflowServiceHostFactory to enable our own CreationEndpoint and http enabled ControlEndpoints on xamlx hosted workflows. I do not control the workflow content but I do control the hosting, therefore I want any workflows defined in xaml to take the protocolMapping default for endpoint configuration based on the scheme which I will define at a higher level web.config. However I would also like to be able to define my own CreationEndpoint and ControlEndpoint on the same workflow service host using the AddServiceEndpoint method from within my host factory.

    If I do not specify a binding for my ServiceEndpoints then i get an exception from the AddServiceEndpoint method.

    Therefore with a mix of explicitly and implicitly defined endpoints, how can I mandate the binding in one place, preferably configuration?

    Thanks,
    Pete

    Tuesday, March 23, 2010 5:38 AM
  • You can create your control endpoint explicitly, and then invoke AddDefaultEndpoints() method, which will add the default endpoints to your service using the bindings defined in the protocol mapping table in the higher level web.config.

    Tuesday, March 23, 2010 2:29 PM
    Moderator
  • OK. I'm already doing this in my service host factory. In fact AFAIK, using that method is the only way to support declaratively defined workflow endpoints on a custom service host factory without specifying the endpoint configuration in config. However, that still does not solve my problem of being able to use the protocolMapping section for my explicitly defined endpoints that I add via AddServiceEndpoint.
    Tuesday, March 23, 2010 6:56 PM
  • You cannot use the protocol mapping for explicitly defined endpoints. The protocol mapping was designed only for default endpoints. That is by design.

     

    • Marked as answer by PeteGoo Wednesday, March 24, 2010 1:08 AM
    Tuesday, March 23, 2010 10:40 PM
    Moderator
  • Thanks. Would you happen to know the reason behind that design? It seems to me that introducing yet another way of configuring endpoints which can only be consumed in one narrow scenario is not simplifying WCF configuration.
    Wednesday, March 24, 2010 1:08 AM