I have the following in the client app.config.
<client>
<endpoint address=""
binding="basicHttpBinding" bindingConfiguration="SecureBinding"
contract="Project.Services.Contract.IMyContract" name="Endpoint_Default">
<identity>
<servicePrincipalName value="host/mikev-ws" />
</identity>
</endpoint>
</client>
I have the following code which sets up an endpoint during runtime.
private EndpointAddress GetEndpoint(string serverAddress, string serviceName)
{
string endpointURL = string.Format("http://{0}/Services/{1}.svc"
, serverAddress, serviceName);
EndpointIdentity spn = EndpointIdentity.CreateSpnIdentity("host/mikev-ws");
Uri uri = new Uri(endpointURL);
EndpointAddress endpoint = new EndpointAddress(uri, spn);
return endpoint;
}
How can I set the contract value at runtime?
thank you
You don’t associate the contract with the
EndpointAddress, you associate it with theServiceEndpoint. And in turn, you also associate yourEndpointAddresswith theServiceEndpointas below:Ultimately, it is this instance of
ServiceEndpointthat should be added to theServiceHost: