WCF,谁打来的? IIS自托管多个网站,互相调用
我在网站上托管了 WCF 服务。我在同一个网站上有多个绑定。每个网站都可以调用另一个网站上的 WCF 服务。
因此,客户端使用的端点是动态地址。
问:是否可以知道调用者在访问主机时使用的地址是什么?
我正在寻找类似于以下内容的内容,而不必将其作为参数发送。
HttpContext.Current.Request.ServerVariables["SERVER_NAME"]
客户端示例
// 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();
主机示例
public class EchoService : IEchoService
{
public string Echo()
{
return "Echo: " + {something like WCF.Caller.EndPoint.Address};
}
}
输出类似于
Echo: http://www.helloworld.com
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

答案是:
返回:
The answer is:
Returns: