我正在使用 2 种方法构建如下 RESTful 服务(注意:我将 ASPNETCompatilibilityMode 设置为 true):
[WebInvoke]
string TestMethodA()
{
string test = HttpContext.Current.Request.Form["xml"];
}
[WebInvoke]
string TestMethodB(string res)
{
string xml = res;
}
现在,在构建客户端以将参数传递给 MethodA 时,我执行以下操作:
request.AddParameter("xmlString", HttpUtility.HtmlEncode(requestBody));
为了向 MethodB 发送消息,我执行以下操作:
request.AddParameter("text/xml",requestBody, ParameterType.RequestBody);
现在的问题是:
客户端如何知道如何传递参数?客户端不知道服务器实现。
发送请求的客户端正在使用 RestSharp Api。