Reputation: 838
I want to Use WCF Service in Asp.net I had Add Refrence in Web site.i don't want to Update my Web.Config File.
I want to Handle WCF Service from Code Behind.All Configuration property like
WSHttpBinding
EndpointIdentity
Uri
ContractDescription
handle form code behind.
Upvotes: 0
Views: 1517
Reputation: 7844
You need to create an end point using the address and also based on the binding supported by the web service, you can create the Binding and then you will just create the proxy and consume the service.
// Specify an end point address of the service
EndpointAddress endpointAdress = new EndpointAddress(serviceUrl);
// Create the binding to be used by the service
BasicHttpBinding binding1 = new BasicHttpBinding();
//customize the binding configurations like the ones below
binding.SendTimeout = TimeSpan.FromMinutes( 1 );
binding.OpenTimeout = TimeSpan.FromMinutes( 1 );
binding.CloseTimeout = TimeSpan.FromMinutes( 1 );
binding.ReceiveTimeout = TimeSpan.FromMinutes( 10 );
//create the client proxy using the specific endpoint and binding you have created
YourServiceClient proxy = new YourServiceClient(binding1, endpointAddress);
Or you can use the ChannelFactory
to follow a generic approach which is shown in the How-To guide here
Upvotes: 1