Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WCF 3.5查找客户端用于访问服务的url(服务器端)_Wcf - Fatal编程技术网

WCF 3.5查找客户端用于访问服务的url(服务器端)

WCF 3.5查找客户端用于访问服务的url(服务器端),wcf,Wcf,我试图找到客户端用来访问服务器的url(在服务器端)。我尝试了以下方法: Uri url = OperationContext.Current.Channel.RemoteAddress.Uri; Uri url = OperationContext.Current.Channel.Local.Uri; Uri url = OperationContext.Current.EndpointDispatcher.EndpointAddress.Uri; 但这些措施似乎都不起作用。它们都返回服务器

我试图找到客户端用来访问服务器的url(在服务器端)。我尝试了以下方法:

Uri url = OperationContext.Current.Channel.RemoteAddress.Uri;
Uri url = OperationContext.Current.Channel.Local.Uri;
Uri url = OperationContext.Current.EndpointDispatcher.EndpointAddress.Uri;
但这些措施似乎都不起作用。它们都返回服务器名(使用完全限定的域,例如myserver.mydomain.local)。即使我使用myserver/myservice.svc,它也会得到全名

目前,我还没有可以测试的服务和域。请访问mywebsite.com/myservice.svc查看它是否有机器名

我希望(从服务器)获得的结果是:

而不是


这就是目前正在发生的情况。

如果您有权访问
HttpContext
,则可以使用
HttpContext.Current.Request.Url.ToString()
OperationContext.Current.IncomingMessageHeaders.to


应该给出客户端用来连接到服务器的Uri。

Jon。我也有同样的问题。这个问题已经解决了吗?Jon,@OammieR,你是如何解决这个问题的?可能是@KumarHarsh的重复-请参阅以下答案: