如何实现方法调用以在ServiceStack
中生成此请求?
[Route("/publishmanifest", "POST")]
public class PublishManifest: List<string>, IReturn<bool> {}
To accept requests like:
POST /getconsignments
[
"ABC1234",
"ABC5678",
"ABC9122"
]
我尝试过类似的事情:
var client = new Client(new JsonServiceClient("www.website.com"));
var result = client.PublishManifest(myconnotes.ConsignmentNumbers.ToArray());
public class Client
{
private readonly ServiceClientBase _serviceClientBase;
public Client(ServiceClientBase serviceClientBase)
{
_serviceClientBase = serviceClientBase;
}
public bool PublishManifest(PublishManifest request)
{
var result = _serviceClientBase.Post(request.ConsignmentNumbers.ToArray());
return result;
}
}
但这不起作用,该怎么做?
由于
答案 0 :(得分:2)
要调用ServiceStack服务,您只需发送其填充的Request DTO,例如:
var client = new JsonServiceClient("http://www.website.com");
var request = new PublishManifest();
request.AddRange(myconnotes.ConsignmentNumbers.ToArray());
var response = client.Post(request);