【WCF Restful】Post传参示范(wcf猫协会)

网友投稿 513 2022-09-20

【WCF Restful】Post传参示范(wcf猫协会)

【WCF Restful】Post传参示范(wcf猫协会)

1、传多个参数

接口定义:(ResponseFormat与RequestFormat分别将相应参数序列化、请求参数反序列化)

[OperationContract]

[WebInvoke(UriTemplate = "api/fun2", Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]

string TestFun2(string p1,string p2);

实现:

public string TestFun2(string p1, string p2)

{

return p1+p2;

}

调用:

HttpHelper.cs

2、传对象

接口定义:

[OperationContract]

[WebInvoke(UriTemplate = "api/fun", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, Method = "POST", BodyStyle = WebMessageBodyStyle.Bare)]

string TestFun(TestModel data);

实现:

调用:

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:git转换换行符LF与CRLF转换问题-Windows系统和Linux系统差异统一
下一篇:#yyds干货盘点#Nginx/HAProxy负载均衡原理及应用场景
相关文章

 发表评论

暂时没有评论,来抢沙发吧~