Tag: rest

超媒体链接Servicestack新API

我正在评估如何向DTO响应添加超媒体链接。 虽然没有标准,但在响应中添加List DTO似乎是建议的方法 。 您是否知道使用ServiceStack框架的任何实现示例或参考? 添加列表对我来说没问题,但我怀疑的是在哪里放置以下链接的逻辑(在服务或包含状态机的专用类中?)以及解决路由的位置(filter?) 谢谢。 [更新]从ServiceStack版本v3.9.62开始,可以通过EndpointHost.Config.Metadata.Routes.RestPath访问路由配置,因此tgmdbm提供的解决方案可以在不需要“IReturn + Routes属性”的情况下得到改进,只需使用元数据.Routes信息。 实际上,可以查询所有服务元数据并将其用于横切关注点。 Servicestack岩石。

如何在原始请求包含内容时克隆HttpRequestMessage?

我正在尝试使用此答案中概述的方法克隆请求: https : //stackoverflow.com/a/18014515/406322 但是,如果原始请求具有内容,则会收到ObjectDisposedException。 你如何可靠地克隆HttpRequestMessage?

将WCF服务转换为RESTful应用程序?

嘿,我没有把wcf变成一个宁静的服务。 所以我想知道是否有人可以在这里启动WCF服务应用程序时采用基本代码: using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.ServiceModel.Web; using System.Text; namespace WcfService1 { // NOTE: You can use the “Rename” command on the “Refactor” menu to change the interface name “IService1” in both code and config file together. [ServiceContract] public interface IService1 { [OperationContract] string GetData(int value); [OperationContract] CompositeType […]

WCF RESTful服务中的访问请求正文

如何在WCF REST服务中访问HTTP POST请求正文? 这是服务定义: [ServiceContract] public interface ITestService { [OperationContract] [WebInvoke(Method = “POST”, UriTemplate = “EntryPoint”)] MyData GetData(); } 这是实施: public MyData GetData() { return new MyData(); } 我虽然使用以下代码来访问HTTP请求: IncomingWebRequestContext context = WebOperationContext.Current.IncomingRequest; 但IncomingWebRequestContext只允许访问标题,而不是正文。 谢谢。

如何在C#中使用REST,包括PUT,POST和DELETE?

我有一个我需要在C#中使用的REST Web服务。 我需要支持的不仅仅是GET请求。 我需要REST完成的所有工作,包括GET,PUT,POST和DELETE。 与此接口的最佳方式是什么? 我没有看到任何HTTPRequest能够进行POST或GET以外的任何事情,除非你构建自己的头文件(我不喜欢) 是否有一些简单轻量的方法可以在C#中完全使用REST Web服务?

将文件从Flex上传到WCF REST Stream问题(如何在REST WS中解码多部分表单post)

该系统是与WCF REST Web服务通信的Flex应用程序。 我正在尝试将文件从Flex应用程序上传到服务器并遇到一些问题,我希望有人能够提供帮助。 我在Flex应用程序中使用FileReference来浏览和上传此处定义的文件: http://blog.flexexamples.com/2007/09/21/uploading-files-in-flex-using-the-filereference-class/ 然后我在WCF REST Web服务(使用WCF 4 REST服务的项目类型)中接收文件作为Stream(在调试器中显示为System.ServiceModel.Dispatcher.StreamFormatter.MessageBodyStream) [WebInvoke(Method = “POST”, UriTemplate = “_test/upload”)] public void UploadImage(Stream data) { // TODO: just hardcode filename for now var filepath = HttpContext.Current.Server.MapPath(@”~\_test\testfile.txt”); using (Stream file = File.OpenWrite(filepath)) { CopyStream(data, file); } } private static void CopyStream(Stream input, Stream output) { var buffer = new […]

如何使用Restsharp反序列化Xml列表?

我有这样的xml 1 1 1 0 2 1 2 0 … 我想将这个xml列表反序列化为POCO对象 public class Account { public string AccountId { get; set; } public string AccountTypeId { get; set; } public string AccountTypeName { get; set; } public string AccountBankId { get; set; } public string AccountBankName { get; set; } public string AccountSaldo { get; […]

无法加载文件或程序集“Microsoft.AI.Web”或其依赖项之一。 该系统找不到指定的文件

成功发布我的Web Api到Azure后,当我尝试点击API时,我得到以下错误。 这是api的链接 WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. 注意:程序集绑定失败日志记录会导致一些性能损失。 要关闭此function,请删除注册表值[HKLM\Software\Microsoft\Fusion!EnableLog] 。

WCF Restful Service的Http Post格式

嘿,超级新手问题。 考虑以下WCF函数: [ServiceContract] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)] public class Service1 { private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); [WebInvoke(UriTemplate = “”, Method = “POST”, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare) ] public SomeObject DoPost(string someText) { … return someObject; 在小提琴手中,我的请求标题和正文会是什么样子? 谢谢您的帮助。

使用WebGet的可选UriTemplate参数

我试过这些 WCF服务URI模板中的可选参数? Kamal Rawat在博客中发表| 2012年9月4日的.NET 4.5本节介绍如何在WCF Servuce URI inShare中传递可选参数 和 WCF中URITemplate中的可选查询字符串参数 但没有什么对我有用。 这是我的代码: [WebGet(UriTemplate = “RetrieveUserInformation/{hash}/{app}”)] public string RetrieveUserInformation(string hash, string app) { } 如果填充参数,它可以工作: https://127.0.0.1/Case/Rest/Qr/RetrieveUserInformation/djJUd9879Hf8df/Apple 但如果app没有价值,则无效 https://127.0.0.1/Case/Rest/Qr/RetrieveUserInformation/djJUd9879Hf8df 我想让app可选。 怎么做到这一点? 当app没有值时,这是错误: Endpoint not found. Please see the service help page for constructing valid requests to the service.