0

I recently ran into an issue that is throwing me for quite a loop.

I have implemented a custom AuthorizationManager in WCF which first must pull the operation by name. The WCF services are exposed over REST and SOAP endpoints, so I have to check in multiple places to find the information that I need to continue through my authentication process.

Everything has been fine, and I have about 15-20 services running fine, but I just recently ran into a problem where I am unable to pull the operation name using my normal methods.

The code for pull the operation is the following:

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*/

     }
}

This has been useful in pulling the correct operation for both REST and SOAP endpoints, but now the action is empty.

The service definition is the following:

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

Everything seems to be pretty standard, I just can't figure out why this is acting any differently than my other services.

TheJediCowboy
  • 8,924
  • 28
  • 136
  • 208

1 Answers1

0

I realized I was did not check my service definition closely enough, and it was using a [WebInvoke] instead of a [WebGet]. This fixed it.

TheJediCowboy
  • 8,924
  • 28
  • 136
  • 208