Search code examples
wcfwcf-binding

Simple way to create a WCF Binding from an EndpointAddress


Is there a shortcut for creating the most basic WCF Binding based on the address of a given Endpoint?

Endpoint: net.tcp://localhost:7879/Service.svc

Instead of a big block of if statements...

Binding binding = null;

if (endpoint.StartsWith("net.tcp"))
{
    binding = new NetTcpBinding();
}
else if (endpoint.StartWith("http"))
{
    binding = new WsHttpBinding();
}

.
.
.

Is there a shortcut in the Framework library that will do this for me that I just can't find or can I not find it because it doesn't publicly exist?


Solution

  • After looking at the issue deeper I don't really need to read the configuration in manually. Instead I need to send the binding information along with the address and contract.

    http://www.codeproject.com/KB/WCF/WCFDiscovery.aspx?display=PrintAll

    I have built a simple component that serializes the binding information.

    http://nardax.codeplex.com/