HttpOperationHandler Help

Topics: Web Api
Apr 19, 2011 at 5:09 PM
Can a GET request bind to a strongly typed object? I get the below error. This seems like something I can figure out, but I didn't see any examples. This post seems related

The service operation 'GetMatch' will never receive a value for the input parameter 'query' of type 'MatchQuery'. Ensure that a request HttpOperationHandler has an output parameter with a type assignable to 'MatchQuery'.
Here is code from my Resource...
       public class MatchQuery
        {
            public int WinnerId { get; set; }
            public int LooserId { get; set; }
        }

        [WebGet(UriTemplate = "GetMatch?WinnerId={WinnerId}&LooserId={LooserId}")]
        public HttpResponseMessage GetMatch(MatchQuery query)
        {
           ......
        }
Apr 19, 2011 at 8:41 PM

I added a HttpOperationHandlerFactory and a Handler, but now I'm getting the following error. 

The request HttpOperationHandler 'MatchQueryHandler[winnerId, looserId, out matchQuery]' of service operation 'Get' will never receive a value for input parameter 'winnerId' of type 'Int32'. Ensure that a request HttpOperationHandler that executes prior to the 'MatchQueryHandler' HttpOperationHandler has an output parameter with a type assignable to 'Int32' or that the output parameter has the name 'winnerId' and provides a string value that can be parsed as a 'Int32'.

I did fine the GridHandler example in the unit tests and followed it, but I must have missed something.

 


Apr 19, 2011 at 9:54 PM

I had a conflicting method in my Resource. Once I removed it, it started working.

Nov 23, 2011 at 5:23 AM

Hello ssuing, Could you please show me your MatchQueryHandler and handler factory code?

I'm not sure how to implement those handlers.

Thank you very much.