質問

WCFサービスがあります。 GetとSaveという2つのメソッドがあります。アプリケーションがGetとSaveの両方を使用できるようにしながら、サービスを使用するサードパーティにGetメソッドのみを公開します。

OperationContractにないメソッドを使用する方法はありますか?リクエストのホスト名を検証し、それがアプリケーションのホスト名である場合にのみアクセスを許可することを考えています。

役に立ちましたか?

解決

Get Set の両方を OperationContracts として持つ2番目の ServiceContract を作成しないのはなぜですか?次に、この2番目の契約に到達できるユーザーをロックダウンできます。

[ServiceContract]
public interface IFoo
{
    [OperationContract]
    void Get();
}

[ServiceContract]
public interface IFooInternal : IFoo
{
    [OperationContract]
    void Set();
}

他のヒント

ホストのIPアドレスを識別するコードは次のとおりです。

string GetAddressAsString()
{
           RemoteEndpointMessageProperty clientEndpoint =
                        OperationContext.Current.IncomingMessageProperties[
                        RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;

                    if (clientEndpoint != null)
                    {
                        return String.Format("{0}:{1}", clientEndpoint.Address, clientEndpoint.Port);
                    }
                    return "Failed to identify address";
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top