2013-04-02 42 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