【发布时间】:2014-04-30 16:16:20
【问题描述】:
我正在使用服务堆栈在 C# 中构建一个宁静的服务。
这是我的服务实现。
namespace cloudfileserver
{
[Route("/updatefile", "POST")]
public class UpdateFile
{
public UserFile file { get; set; }
}
public class CloudFileService : Service
{
public InMemoryFileSystem filesystem { get; set; }
private static readonly log4net.ILog logger = log4net.LogManager.GetLogger (typeof(CloudFileService));
public void Post (UpdateFile request)
{
try{
logger.Debug("File received is :" + request.file);
filesystem.addFileSynchronized (request.clientId, request.file);
}catch(Exception e){
logger.Debug(e);
throw e;
}
}
}
}
我正在通过以下 servicestack 客户端代码调用此服务:
JsonServiceClient client = new JsonServiceClient(ENDPOINT);
UpdateFile arg = new UpdateFile();
UserFile file = new UserFile ("x.txt", "piyush");
file.SetFileContent (getByteArrayFromString ("Filecontent"), 0);
arg.file = file;
client.Post<Object>("/updatefile", arg);
问题是每当我通过上述客户端代码进行 post 调用时,在服务器端收到的文件对象为 NULL(我通过将其写入日志文件来验证)。
Here is the File class 正在通过网络发送。
File 类是 serialisable,因为我可以通过 GET 调用正确地发送它。
知道这里可能出了什么问题吗?
【问题讨论】:
标签: c# rest servicestack