我有一个 ServiceStack REST 服务(PUT 和 POST),我用 fiddler 测试过,如果没有出现错误,我会返回
new HttpResult(HttpStatusCode.OK);
现在我正在使用服务堆栈客户端测试相同的 REST 服务,我有:
var client = new XmlServiceClient("url"));
client.Post<ChangeServerLicenseDto>("", new ChangeServerLicenseDto()
{ServerName = model.ServerName});
当我这样做时,我得到了 REST 服务的异常
return new HttpResult(HttpStatusCode.OK)
并且引发的错误是:
500 (Error in line 1 position 76. Expecting element 'ChangeServerLicense'
from namespace ''.. Encountered 'Element' with name 'HttpStatusCode',
namespace 'http://schemas.datacontract.org/2004/07/System.Net'.)
我的客户端代码在 MVC 操作方法 (POST) 中。
我的 RestService 数据合同是:
[DataContract(Name = "ChangeServerLicense", Namespace = "")]
[RestService("url", "POST", "application/xml")]
public class ChangeServerLicenseDto
{
[DataMember(Name = "ServerName", Order = 1)]
public string ServerName { get; set; }
}