Si vous avez un serveur qui héberge plusieurs points de terminaison du même type à des adresses différentes, est-il possible d'identifier l'adresse à partir de laquelle une demande particulière est venue? Dire à des fins de journalisation?Comment identifiez-vous le point de terminaison WCF qui a appelé votre opération?
exemple Contrived:
_serviceHost = new ServiceHost(
typeof(Service),
new Uri("http://localhost:8000/SomeAddress"));
_serviceHost.AddServiceEndpoint(
typeof(IService),
new BasicHttpBinding(),
string.Empty);
_serviceHost2 = new ServiceHost(
typeof(Service),
new Uri("http://localhost:8000/SomeOtherAddress"));
_serviceHost2.AddServiceEndpoint(
typeof(IService),
new BasicHttpBinding(),
string.Empty);
[ServiceContract()]
public interface IService
{
[OperationContract]
void Operation();
}
public class Service
{
void Operation()
{
//Which endpoint made this call?
}
}
Je préfère ne pas créer une instance singleton et le transmettre avec un id.
Un grand merci, cela fonctionnera. – RMK