Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

This is a rookie question:

I have an app that consumes a web service. In order to get rid of the app.config file I generated the client class using the wsdl.exe (instead of adding a service reference to the project).
Is there any way to programmatically configure the HttpBinding for this kind of client?

Thanks in advance!
Posted

1 solution

Check this code that hosts a wcf webservice on a console.

ServiceHost host = new ServiceHost(typeof(MyService));
ContractDescription description = ContractDescription.GetContract(typeof(IMyService));
Binding binding = new WSHttpBinding();
EndpointAddress address = new EndpointAddress("http://localhost/MyService");
ServiceEndPoint endpoint = new ServiceEndpoint(description, binding, address);

host.Description.Endpoint.Add(endpoint);
host.Open();


Good luck!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900