2011-03-03 33 views
1

我託管的網站上的WCF服務。我在同一個網站上有多個綁定。每個網站都可以在另一個網站上調用WCF服務。WCF,是誰打來的? IIS自主辦了多個網站,呼叫對方

正因爲如此,客戶端使用的端點是動態地址。

問:是否有可能知道當主機打到主機時使用的地址是什麼?

我正在尋找類似如下的東西,而無需將其發送的PARAM。

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 

回答

1

答案是:

System.ServiceModel.OperationContext.Current.IncomingMessageHeaders.To 

返回:

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