How to pass several parameters to the WCF recreation service?

I am developing a WCF REST service in C #. It works fine for a single parameter. Now I need to expand it to support several parameters. Please help me in this matter.

Thanks in advance...

Use the following declaration in the interface:

[OperationContract]
[WebInvoke(Method = "POST",
    ResponseFormat = WebMessageFormat.Xml,
    RequestFormat = WebMessageFormat.Xml,
    BodyStyle = WebMessageBodyStyle.WrappedRequest,
    UriTemplate = "login")]
resLogin Login(reqLogin rData, int floorId);
+5
source share
2 answers

Check out the UriTemplate options . You can use a QueryString or a URL to pass in a parameter floorId.

URI path parameter

[WebInvoke(Method = "POST", UriTemplate = "login/floor/{floorId}")]
resLogin Login(reqLogin rData, int floorId);

QueryString Parameter

[WebInvoke(Method = "POST", UriTemplate = "login?floorId={floorId}")]
resLogin Login(reqLogin rData, int floorId);
+7
source

Add BodyStyle to OperationContract

[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest)]
+2
source

All Articles