【问题标题】:WCF, who is calling? IIS self hosted with multiple websites, calling each otherWCF,谁在召唤? IIS自托管多个网站,互相调用
【发布时间】:2011-03-03 01:04:20
【问题描述】:

我在网站上托管了 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

【问题讨论】:

    标签: c# wcf wcf-binding wcf-client wcf-hosting


    【解决方案1】:

    答案是:

    System.ServiceModel.OperationContext.Current.IncomingMessageHeaders.To
    

    返回:

    http://www.helloworld.com/Services/EchoService.svc
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-07-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-15
      • 1970-01-01
      相关资源
      最近更新 更多