I'm currently looking at the OperationContect.Current properties. Is there a (nested) property the will always return the machine name of the client? I'm currently using net.tcp binding, but would like to support additional bindings in the future.
Using .NET 3.5 SP1
With the service running, right click the project that will contain the WCF client proxy and select Add > Service Reference. In the Add Service Reference Dialog, type in the URL to the service you want to call and click the Go button. The dialog will display a list of services available at the address you specify.
Sure - you can copy the path+filename for the WSDL and paste that into the "Add Service Reference" dialog box in Visual Studio (or just type int the full path + WSDL file name). Alternatively, you can use the svcutil.exe command line utility to convert the WSDL file to your client proxy class.
You can get the remote endpoint's IP address from the current OperationContext's IncomingMessageProperties, eg:
RemoteEndpointMessageProperty messageProperty = OperationContext.Current.IncomingMessageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
Console.WriteLine("Remote address is: {0}", messageProperty.Address);
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