我可以得到WCF来电网址...? [英] Can I get the WCF Caller Url...?

查看:103
本文介绍了我可以得到WCF来电网址...?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个是从不同的地方调用WCF服务

I have a WCF service that is called from various places

我有一个方法来获取主叫方的IP地址和主机名。

I have a method to get the ip and hostname of the caller.

不过,我希望能够得到,如果它的另一个服务,aspx页面,等了正在通话的主叫方的完整URL。

But I was hoping to be able to get the full url of the caller if it's another service, aspx page, etc that is making the call.

这可能吗?

目前我有什么本质上是这样的:

Currently what I have is essentially this:

public static string GetHostName()
{
    var hostName = "UNKOWN";

    try
    {
        var remoteEndpointMessageProperty = OperationContext.Current.IncomingMessageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
        hostName = remoteEndpointMessageProperty.Address;

        var hostEntry = Dns.GetHostEntry(hostName);
        hostName = hostEntry.HostName;
    }
    catch
    {
    }

    return hostName;
}

是的,我知道code不是当前干净的(空的catch,等),它的概念在目前的证明......

Yes, I know the code is not currently clean (empty catch, etc), it's a proof of concept at the moment...

推荐答案

这是不可能的。所有你能希望得到的是调用者的IP地址,当然包含在请求消息和最终的HTTP标头的任何信息。

That's not possible. All you can hope of getting is the IP address of the caller and of course any information contained in the request message and eventual HTTP headers.

这篇关于我可以得到WCF来电网址...?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆