I have a WCF service that works ok if I create the service without specifying any binding or endpoint (it reads it from the generated values in the App.config when I registe
Most of the values in the App config are also properties in the binding and can be recreated programatically. Personally, I use a method such as the one below to create the binding
public static BasicHttpBinding CreateBasicHttpBinding()
{
BasicHttpBinding binding = new BasicHttpBinding();
binding.AllowCookies = false;
binding.ReceiveTimeout = new TimeSpan(0, 10, 0);
binding.OpenTimeout = new TimeSpan(0, 1, 0);
binding.SendTimeout = new TimeSpan(0, 1, 0);
// add more based on config file ...
//buffer size
binding.MaxBufferSize = 65536;
binding.MaxBufferPoolSize = 534288;
binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
//quotas
binding.ReaderQuotas.MaxDepth = 32;
binding.ReaderQuotas.MaxStringContentLength = 8192;
// add more based on config file ...
return binding;
}
And I use something like this for creating my Endpoint address
public static EndpointAddress CreateEndPoint()
{
return new EndpointAddress(Configuration.GetServiceUri());
}
The serviceUri will be the service URL such as http://www.myuri.com/Services/Services.svc/basic
Finally to create the service client
Binding httpBinding = CreateBasicHttpBinding();
EndpointAddress address = CreateEndPoint();
var serviceClient = new MyServiceClient(httpBinding, address);