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);
在OperationContract上添加BodyStyle
[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest)]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.