I'm developing WCF REST service in C#. It works fine for a single parameter. Now I need to extend it to support multiple parameters. Please help me on this issue.
Thanks in advance...
Use following declaration in interface:
[OperationContract]
[WebInvoke(Method = "POST",
ResponseFormat = WebMessageFormat.Xml,
RequestFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.WrappedRequest,
UriTemplate = "login")]
resLogin Login(reqLogin rData, int floorId);
Take a look at UriTemplate parameters. You can use the QueryString or URL path to pass in the floorId
parameter.
[WebInvoke(Method = "POST", UriTemplate = "login/floor/{floorId}")]
resLogin Login(reqLogin rData, int floorId);
[WebInvoke(Method = "POST", UriTemplate = "login?floorId={floorId}")]
resLogin Login(reqLogin rData, int floorId);
Add BodyStyle on OperationContract
[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest)]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With