【发布时间】:2019-09-03 06:06:13
【问题描述】:
我有一个需要被 WCF Post 方法接受的 json 字符串。我已经使用类来接受请求并且工作正常。但我想在不使用类的情况下动态接受请求。我可以使用字符串、Jobject 或任何其他数据类型来接受相同的吗?
我的帖子方法。使用流和字符串时我得到空值
[OperationContract(Name = "PostResponse")]
[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, UriTemplate = "PostJsonResponse?Plugin={plugin}&Action={action}", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
Stream PostJsonResponse(String plugin, String action, Stream jsonStr);
JSON 字符串。我们要在 Post 方法中将下面的 json 数据绑定到 jsonStr(Parameter)
{"short_description":"BF INC 008489","description":"","u_issue":"Paper Jam","business_service":"Printer and Copier Devices","impact":"3","urgency":"3"}
【问题讨论】:
-
您的问题尚不清楚,无论如何,如果您想传递单个字符串,则在您的方法中使用字符串 yourVariableName 作为参数,但从您上传的图像来看,您似乎需要一个 Class 类型。目前的做法没有错