c# - Can't execute WCF REST services for POST and GET with basic endpoint address -
i'm attempting create set of wcf rest services following endpoints (among others):
- /session (supports http post , creates session object. returns sid in response)
- /session/{sid} (supports http , returns json object representing created session)
here definitions in service contract:
[operationcontract] [webinvoke(method="post", requestformat=webmessageformat.json, responseformat=webmessageformat.json, uritemplate="session")] string initializesession(stream contents); [operationcontract] [webinvoke (method="get", requestformat=webmessageformat.json, responseformat=webmessageformat.json, uritemplate="session/{sid}")] string retrievesession(string sid);
without operation defined can invoke post fine , expected sid in response. when operationcontract included, invoking post throws:
500 system.servicemodel.serviceactivationexception
with no additional data in response (very helpful) though i've got
<servicedebug includeexceptiondetailinfaults="true"/>
defined in service behavior in web.config.
do operationcontract definitions correct i'm trying achieve (assuming i'm trying achieve restful)? if ideas on silly config option i'm missing allow access both operations?
try changing operation contracts of , post methods thing below: 1. post [operationcontract] [webinvoke(uritemplate = "session", method = "post", requestformat = webmessageformat.json, responseformat = webmessageformat.json, bodystyle = webmessagebodystyle.bare)] 2. [operationcontract] [webinvoke(uritemplate = "session/{sid}", method = "get", responseformat = webmessageformat.json, bodystyle = webmessagebodystyle.wrappedrequest)]
Comments
Post a Comment