문제

WCF 서비스가 있습니다. 여기에는 두 가지 방법이 있습니다. 응용 프로그램은 Get and Save를 모두 소비 할 수 있어야하는 동안 서비스를 소비 할 제 3 자에게 GET 메소드 만 노출하고 싶습니다.

OperationContract가 아닌 방법을 소비하는 방법이 있습니까? 요청의 호스트 이름을 확인하고 응용 프로그램의 호스트 이름 인 경우에만 액세스 권한을 부여 할 생각입니다.

도움이 되었습니까?

해결책

두 번째를 만들지 않겠습니까? ServiceContract 그것은 둘 다 가지고 있습니다 Get 그리고 Set ~처럼 OperationContracts? 그런 다음이 두 번째 계약에 도달 할 수있는 사람을 잠글 수 있습니다.

[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