1

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
4

1 に答える 1

1

答えは次のとおりです。

System.ServiceModel.OperationContext.Current.IncomingMessageHeaders.To

戻り値:

http://www.helloworld.com/Services/EchoService.svc
于 2011-03-03T02:16:56.423 に答える