servicestack,Rest,servicestack" /> servicestack,Rest,servicestack" />

Rest ServiceStack JsonServiceClient:SendAsync使用了错误的路径,是否忽略路由属性?

Rest ServiceStack JsonServiceClient:SendAsync使用了错误的路径,是否忽略路由属性?,rest,servicestack,Rest,servicestack,我正在Xamarin应用程序中使用JsonServiceClient,如下所示: JsonServiceClient client = new JsonServiceClient("https://my.domain.com/"); SetHeaders(client); var request = ...; // this is IRequest<T> var result = await client.SendAsync(request); // <-

我正在Xamarin应用程序中使用JsonServiceClient,如下所示:

JsonServiceClient client = new JsonServiceClient("https://my.domain.com/");
SetHeaders(client);

var request = ...; // this is IRequest<T>
var result = await client.SendAsync(request); // <-- FAILS, can't find service
问题在于调用中使用的路径错误,并且不遵循Route属性:

https://my.domain.com/json/reply/Login

这里,ServiceStack客户端使用默认的
/json/reply
路径,即使我在DTO中定义了
路由
属性

如果我更改了
客户端
实例上使用的方法,而改为使用
PostAsync
,则路径是正确的,调用按预期工作:

JsonServiceClient client = new JsonServiceClient("https://my.domain.com/");
SetHeaders(client);

var request = ...; // this is IRequest<T>
var result = await client.PostAsync(request); // <-- WORKS!
JsonServiceClient客户端=新的JsonServiceClient(“https://my.domain.com/");
SetHeaders(客户端);
var请求=…;//这是IRequest

var result=wait client.PostAsync(请求);// 如果要使用ServiceStack的generic
Send*
API,则服务客户端需要通过使用从其基类推断出的、非必需的或API注释请求DTO来显式推断要使用的动词


否则,
Send*
API被设计为回退使用ServiceStack。

好的,谢谢。但是Route属性确实包含动词(字符串格式),这不是可以使用的,避免了额外的注释?=)@Ted路由没有说明客户端应该使用什么,只说明哪些自定义用户定义的路由可用于该请求DTO。发送请求的动词+填充请求DTO属性的组合是用于查找最佳匹配的用户定义路由的组合(当匹配可用时)。
JsonServiceClient client = new JsonServiceClient("https://my.domain.com/");
SetHeaders(client);

var request = ...; // this is IRequest<T>
var result = await client.PostAsync(request); // <-- WORKS!