WebサイトでホストされているWCFサービスがあります。同じウェブサイトに複数のバインディングがあります。各Webサイトは、別のサイトのWCFサービスを呼び出すことができます。
このため、クライアントが使用するエンドポイントは動的アドレスです。
Q:発信者がホストに到達したときに使用しているアドレスを知ることはできますか?
パラメータとして送信せずに、次のようなものを探しています。
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