How to change WCF service endpoints?

i having more than three web services, In that it is the main site, while others are client sites.

There is one text field available in my user interface. In this text box, I need to specify the address of the destination endpoint from this text box. Value I need to call customer service.

for example:

Client Endpoint Name1:

                 http://localhost:1524/WebServiceService.svc" 

Client2 Endpoint Service Name:

By

Rajagopalk

                 http://localhost:8085/WebServiceService.svc" 

if I give “localhost: 1524” in the text field, Client1 Service will call, if I give “localhost: 8085” in the text field Client2 Service will call,

+3
source share
1 answer

WCF IIS? IIS , *.svc.

, - , IIS.

, web.config( - ASP.NET) (applicationName).exe.config, - :

<client> 
   <endpoint name="YourEndpointName"
       address="http://localhost:8085/WebServiceService.svc" 
       binding="......." bindingConfiguration="............."
       contract="..................." />
</client>

- address= <endpoint>.

, :

MyServiceProxy client = new MyServiceProxy("name of endpoint configuration");

.

: , - :

// create custom endpoint address in code - based on input in the textbox
EndpointAddress epa = new EndpointAddress(new Uri(textbox.Text));

// instantiate your cilent proxy using that custom endpoint address 
// instead of what is defined in the config file
MyServiceProxy client = new MyServiceProxy("name of endpoint configuration", epa);
+6

Source: https://habr.com/ru/post/1732128/


All Articles