【发布时间】:2012-06-01 16:15:29
【问题描述】:
我创建了一个具有以下签名的 WCF POST 服务。这在 IIS 中成功托管,我可以在服务的帮助页面中看到它:
[OperationContract]
[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped,
RequestFormat = WebMessageFormat.Xml,
ResponseFormat = WebMessageFormat.Xml,
Method = "POST",
UriTemplate = "TestMethod/{lang}/{str}/{selectedstring}/")]
string TestMethod(string lang, string str, string selectedstring, string mylist, int testval);
在服务的帮助页面上,该方法正确显示为
TestMethod/{lang}/{str}/{selectedstring}/ || POST || Service at http://localhost:86/MyRestService.svc/TestMethod/{LANG}/{STR}/{SELECTEDSTRING}/
我正在尝试使用带有以下提到选项的提琴手调用此服务(基于一些在博客上的查找):
方法:发布
URL - 'http://servername:86/MyRestService.svc/TestMethod/en-us/str1/qad11/'
要求。标题: 用户代理:提琴手 主机:服务器名称:86 内容类型:application/xml
请求正文:
<TestMethod xmlns="http://tempuri.org/"><mylist>string val</mylist><testval>3</testval></TestMethod>
但是它总是给我一个 HTTP 结果代码 411(需要长度),当我尝试从我的 .net 测试存根调用服务时出现同样的错误。
【问题讨论】:
标签: wcf rest post httpwebrequest http-post