我们将C# web服务从ServiceStack V4.0.31升级到V5.1.0。在具有单开发运行时的linux环境中,我们使用以下软件包。
<package id="ServiceStack" version="5.1.0" targetFramework="net45" />
<package id="ServiceStack.Client" version="5.1.0" targetFramework="net45" />
<package id="ServiceStack.Common" version="5.1.0" targetFramework="net45" />
<package id="ServiceStack.Interfaces" version="5.1.0" targetFramework="net45" />
<package id="ServiceStack.Redis" version="5.1.0" targetFramework="net45" />
<package id="ServiceStack.Text" version="5.1.0" targetFramework="net45" />升级之后,我们在处理一些客户端请求时出现了问题。我们的请求DTO包含几个路由,但下面的一个总是失败。
[FallbackRoute("/{Path*}")]
public class S3Request : IRequiresRequestStream {
public Stream RequestStream { get; set; }
}当客户端发出
GET http://endpoint:1310/name/clients/C1/sites/G1 (港口和航线并不重要,只是个例子)。我们收到了一个400坏的请求,下面是错误响应。
{
"ResponseStatus": {
"ErrorCode": "ArgumentException",
"Message": "Could not find property Path on S3Request",
"StackTrace": " at ServiceStack.Host.RestPath.CreateRequest (System.String pathInfo, System.Collections.Generic.Dictionary`2[TKey,TValue] queryStringAndFormData, System.Object fromInstance) [0x000c9] in <629ec152372546cf812fe4a698c7a784>:0 \n at ServiceStack.Host.RestHandler.CreateRequest (ServiceStack.Web.IRequest httpReq, ServiceStack.Web.IRestPath restPath, System.Collections.Generic.Dictionary`2[TKey,TValue] requestParams, System.Object requestDto) [0x0001e] in <629ec152372546cf812fe4a698c7a784>:0 \n at ServiceStack.Host.ServiceController+<>c__DisplayClass26_0.<RegisterService>b__0 (ServiceStack.Web.IRequest req) [0x00035] in <629ec152372546cf812fe4a698c7a784>:0 \n at ServiceStack.Host.Handlers.ServiceStackHandlerBase.GetCustomRequestFromBinder (ServiceStack.Web.IRequest httpReq, System.Type requestType) [0x00018] in <629ec152372546cf812fe4a698c7a784>:0 \n at ServiceStack.Host.RestHandler.CreateRequestAsync (ServiceStack.Web.IRequest httpReq, ServiceStack.Web.IRestPath restPath) [0x00017] in <629ec152372546cf812fe4a698c7a784>:0 \n at ServiceStack.Host.RestHandler+<ProcessRequestAsync>d__14.MoveNext () [0x00125] in <629ec152372546cf812fe4a698c7a784>:0 "
}
}异常被抛出方法ServiceStack.Host.RestPath.CreateRequest(…)在代码的以下区域
for (int i = 0; i < this.TotalComponentsCount; i++) {
string text = this.variablesNames [i];
string key;
if (text == null) {
num++;
} else if (!this.propertyNamesMap.TryGetValue (text.ToLower (), out key)) {
if (!StringExtensions.EqualsIgnoreCase (Keywords.Ignore, text)) {
throw new ArgumentException ("Could not find property " + text + " on " + UrlExtensions.GetOperationName (this.RequestType));
}看来,CreateRequest方法期望propertyNamesMap为路由提供一个条目,但它并不存在。我们想知道V5.1.0API是否需要执行某种在V4.0.31中不需要的路径注册逻辑?
发布于 2018-07-10 00:09:26
您的DTO缺少了请求DTO上的Path属性,除了{ignore}之外,路由上的每个变量都需要匹配请求DTO上的属性。
https://stackoverflow.com/questions/51254466
复制相似问题