How can I change the endpoint address programmatically in the client site?
Endpoints provide the configuration required for the communication and create the complete WCF service application. WCF provides communication for client applications using Endpoints. Endpoints provide the configuration required for the communication and create the complete WCF service application.
WCF formalizes this relationship in the form of an endpoint. The endpoint is the fusion of the address, contract, and binding (see Figure 1-8). Every endpoint must have all three elements, and the host exposes the endpoint. Logically, the endpoint is the service's interface and is analogous to a CLR or COM interface.
The endpoint address is represented by the EndpointAddress class, which contains a Uniform Resource Identifier (URI) that represents the address of the service, an Identity, which represents the security identity of the service, and a collection of optional Headers.
proxy.Endpoint.Address = new EndpointAddress("http://newaddress");
where proxy
is an instance of the client class generated when importing the WSDL. Or you can specify the address when creating the client proxy:
var endpoint = new EndpointAddress("http://newaddress");
var proxy = new SomeClientProxy("BasicHttpBinding_IHelloWorld", endpoint);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With