OperationContractに記載されていないメソッドを使用する
質問
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";
}
所属していません StackOverflow