tags:

views:

237

answers:

2

With WCF, how can I determine who is connecting to my server?

Background: I have a set of WCF clients and servers. I suspect one client is pointed to the wrong server, so I want to log all the connections to that server. I don't know which client it is, so I have to check it on the server side.

+3  A: 

This is easiest in 3.5 via RemoteEndpointMessageProperty; see here.

Marc Gravell
Is there a cleaner syntax than "Dim remoteAddress = CType(OperationContext.Current.IncomingMessageProperties("System.ServiceModel.Channels.RemoteEndpointMessageProperty"), System.ServiceModel.Channels.RemoteEndpointMessageProperty).Address"
Jonathan Allen
Don't know, sorry
Marc Gravell
Well you could at least avoid the string literal (see the "here" link in the answer posted by Marc).
Christian.K
+1  A: 
OperationContext opCtx = OperationContext.Current;
EndpointAddress from = opCtx.IncomingMessageHeaders.From;
Scott Weinstein
No good, the From property is null.
Jonathan Allen