Multiple methods with different parameters WCF REST -


i've been given task implement following using wcf rest:

 resource       post                          put                  delete /device        create new device   list devices  bulk update devices  delete devices 

this isn't problem per-se, problem these functions need different parameters. example, post method takes wsdevice, while method takes wscollectionquery parameter (used querying .. collections). 4 methods take different parameters, have accessible through /device uri.

this should possible in rest (according http://pages.apigee.com/web-api-design-ebook-thank-you-download.html?aliid=1911411 , got table in first place. see page 7).

what have:

[operationcontract, webinvoke(method = "post",     responseformat = webmessageformat.json,     bodystyle = webmessagebodystyle.wrapped,     uritemplate = "/v" + rest_api_version + "/device/?device={device}")] wsresult devicepost(string sessionkey, wsdevice device);  [operationcontract, webinvoke(method = "get",     responseformat = webmessageformat.json,     bodystyle = webmessagebodystyle.wrapped,     uritemplate = "/v" + rest_api_version + "/device/?collectionquery={collectionquery}")] wsresult deviceget(string sessionkey, wscollectionquery collectionquery);  [operationcontract, webinvoke(method = "put",     responseformat = webmessageformat.json,     bodystyle = webmessagebodystyle.wrapped,     uritemplate = "/v" + rest_api_version + "/device/?devices={devices}")] wsresult deviceput(string sessionkey, wsdevice[] devices);  [operationcontract, webinvoke(method = "delete",     responseformat = webmessageformat.json,     bodystyle = webmessagebodystyle.wrapped,     uritemplate = "/v" + rest_api_version + "/device/")] wsresult devicedelete(string sessionkey); 

so i'd have same uritemplate, different outcome depending on passed parameters in message body. know added parameters above in uri, attempt differentiate between uri.

the error i'm getting following:

uritemplatetable not support multiple templates have equivalent path template '/v1/device/?device={device}' have different query strings, query strings cannot disambiguated via literal values. see documentation uritemplatetable more detail. 

i know why i'm receiving error. i'd know how else solve problem? i've looked @ having 1 function taking method = "*" works, can't access parameters other 1 passed in function.

if knows solution or can it's not possible if isn't, it'd much, appreciated!

edit: know can't pass complex types in get, that's issue can worked around.

probably best solution in case use same uritemplate 4 methods:

uritemplate = "/v" + rest_api_version + "/device/?device={device}&collectionquery={collectionquery}&devices={devices}" 

then can check necessary parameter in each case.

quite why doesn't throw ambiguous exception beats me however.


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -