我正在检查servicestack example projects 是否可以调试自托管服务?
namespace StarterTemplates.Common
{
/// <summary>
/// Define your ServiceStack web service request (i.e. the Request DTO).
/// </summary>
[Description("ServiceStack's Hello World web service.")]
[Route("/hello")]
[Route("/hello/{Name*}")]
public class Hello
{
public string Name { get; set; }
}
/// <summary>
/// Define your ServiceStack web service response (i.e. Response DTO).
/// </summary>
public class HelloResponse : IHasResponseStatus
{
public string Result { get; set; }
public ResponseStatus ResponseStatus { get; set; }
}
/// <summary>
/// Create your ServiceStack web service implementation.
/// </summary>
public class HelloService : ServiceBase<Hello>
{
protected override object Run(Hello request)
{
return new HelloResponse { Result = "Hello, " + request.Name };
}
}
}
在端口32下运行。
来自fiddler http://localhost:32/servicestack/xml/syncreply/Hello?Name=World
,但我总是得到404错误。
有什么想法吗?
其他非自我托管的示例作为魅力运行。
任何想法
答案 0 :(得分:3)
自托管服务不在/custompath
下托管,请尝试改为:
http://localhost:32/xml/syncreply/Hello?Name=World
示例项目看起来过时了,因为推荐的创建服务的方法是使用ServiceStack's New API,例如:
public class HelloService : Service
{
public object Any(Hello request)
{
return new HelloResponse { Result = "Hello, " + request.Name };
}
}
还有new routing options可让您使用较短的内容访问相同的服务:
http://localhost:32/xml/reply/Hello?Name=World
如果您已定义自定义路由,则可以使用不同方式请求内容协商,例如:
http://localhost:32/hello?Name=World&format=xml
http://localhost:32/hello.xml?Name=World