2013-04-02 41 views
0

我最近遇到了一個問題,是我扔了一個循環。無法找到DispatchOperation在WCF的擴展GET請求的名稱

我已經在WCF中實現了一個自定義AuthorizationManager,它首先必須通過名稱來提取操作。 WCF服務通過REST和SOAP端點公開,所以我必須檢查多個位置以查找我需要通過身份驗證過程繼續的信息。

一切都很好,我有大約15-20服務運行良好,但我最近遇到了一個問題,我無法使用我的常規方法拉操作名稱。

爲拉操作的代碼如下:

public class AuthorizationManager : ServiceAuthorizationManager 
{ 
    private ServiceEndpoint _endpoint { get; set; } 

    public AuthorizationManager(ServiceEndpoint endpoint) 
    { 
     _endpoint = endpoint; 
    } 
    public override bool CheckAccess(OperationContext operationContext, ref Message message) 
    { 
     var buffer = message.CreateBufferedCopy(Int32.MaxValue); 
     message = buffer.CreateMessage(); 
     var originalMessage = buffer.CreateMessage(); 


     /*Step 1 - Pull Operation*/ 
     string action = operationContext.IncomingMessageHeaders.Action ?? OperationContext.Current.IncomingMessageProperties["HttpOperationName"] as string; 
     DispatchOperation operation = operationContext.EndpointDispatcher.DispatchRuntime.Operations.FirstOrDefault(o => o.Name == action || o.Action == action); 
     Type hostType = operationContext.Host.Description.ServiceType; 
     var operationInfo = hostType.GetMethod(operation.Name); 


     /*Continue here using operationInfo - but operation is null*/ 

    } 
} 

這一直是拉動正確的操作REST和SOAP端點是有用的,但現在的行動是空的。

服務定義如下:

[ServiceContract] 
public interface ICollectionService 
{ 
     [OperationContract] 
     [WebGet] 
     CollectionResponse GetCollection() 
} 

一切都顯得非常標準,我只是想不通,爲什麼這種做法是出於任何不同於我的其他服務。

回答

0

我意識到我沒有仔細檢查我的服務定義,它使用[WebInvoke]而不是[WebGet]。這固定了它。

+0

然後請將問題標記爲已回答。 – ErnieL