I have a WCF service hosted on a website. I have mutliple bindings on the same website. Each website can call the WCF service on another site.
Because of this, the endpoint the client uses is a dynamic address.
Q: Is it possible to know what the address the caller is using when it hits the host?
I am looking for something similar to the following without having to send it as a param.
HttpContext.Current.Request.ServerVariables["SERVER_NAME"]
Client Example
// The endpoint being called is -
// http://www.helloworld.com/Services/EchoService.svc for example.
EchoServiceClient client = new EchoServiceClient("WSHttpBinding_IEchoService", GetEndpoint("EchoService"));
litResponse.Text = client.Echo();
client.Close();
Host Example
public class EchoService : IEchoService
{
public string Echo()
{
return "Echo: " + {something like WCF.Caller.EndPoint.Address};
}
}
Output similar to
Echo: http://www.helloworld.com
The answer is:
System.ServiceModel.OperationContext.Current.IncomingMessageHeaders.To
Returns:
http://www.helloworld.com/Services/EchoService.svc