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

I have developed a client application that makes use of a web service. As most of you know, the client application makes use of it's configuration file to get the endpoint address of the web service. For example:

XML
<client>
  <endpoint address="https://server.local/service.asmx"
      binding="basicHttpBinding" bindingConfiguration="Service"
      contract="ServiceReference.Service" name="Service" />
</client>


Which brings me to my question, how can I dynamically configure the endpoint address of each client without setting the address manually (manually refers to using a method as described in Answer 2) within the configuration file. I was thinking in the line of querying the DNS server, but I am really not sure what the best approach would be?? Any pointers?

Many thanks in advance.
Kind regards,
Posted
Updated 20-Apr-10 1:04am
v4

1 solution

If your requirement is to set the endpoint address through code instead of setting it in the config file, you can do it like this,

ServiceReference.Service service = new ServiceReference.Service();
service.Endpoint.Address = new EndpointAddress("http://localhost/MyServiceTest/Service.asmx");
 
Share this answer
 
Comments
Manoj Goswami ( .NET ) 30-Dec-11 4:54am    
ServiceReference.Service is generating error how to solve this... my code is as below :

System.Web.UI.ServiceReference service = new System.Web.UI.ServiceReference();
service.Endpoint.Address = new EndpointAddress("http://localhost/MyServiceTest/Service.asmx");
Purushotham Agaraharam 26-Sep-12 3:00am    
Hi,I need to take WCF Web.config <endpoint address="https://server.local/service.svc">adress url and dynamically change it in web application Web.config during installation.
Can u Help me

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