wcf-rest

Exposing meta data for a WCF 4.0 Rest Template Service

ε祈祈猫儿з 提交于 2019-12-22 10:38:06
问题 Probably missing something very basic. I created a WCF 4.0 Rest Service. It works no problems when I'm hitting the url from a browser and I'm getting back what I want. But now I want to use that service from a client mvc application (it will also be used by other non .net platforms which is why it's a rest service in the first place). Problem is how do I get a service reference to it so I can start to use it in my c# code? With the new minimal WCF .net 4 config approach and no interface for

Difference between PUT and POST using WCF REST

强颜欢笑 提交于 2019-12-22 06:16:26
问题 I have tried to implement a REST WCF in order to explore difference between PUT and POST verb. I have uploded a file in a location using the service. The service implementation is as folowing: [OperationContract] [WebInvoke(UriTemplate = "/UploadFile", Method = "POST")] void UploadFile(Stream fileContents); public void UploadFile(Stream fileContents) { byte[] buffer = new byte[32768]; MemoryStream ms = new MemoryStream(); int bytesRead, totalBytesRead = 0; do { bytesRead = fileContents.Read

How to consume WCF REST Service in C#?

时光毁灭记忆、已成空白 提交于 2019-12-22 05:34:32
问题 My contract details are below. I am using Json response and request format and also using POST method. How to write a client to consume this service in c#. [OperationContract()] [WebInvoke(UriTemplate = "/RESTJson_Sample1_Sample1Add", Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)] int RESTJson_Sample1_Sample1Add(Int32 a, Int32 b, Int32 c); 回答1: Here I have working code for POST method in WCF REST

WCF Error : Relative end point addresses

爷,独闯天下 提交于 2019-12-21 07:20:35
问题 Um quite new to WCF . I think I have messed up a bit. So this is what I did so far and I ve hosted my WCF service in IIS First the Contracts using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.ServiceModel.Web; using System.Text; using YangkeeServer.dto; namespace YangkeeServer { public class Service1 : IService1 { [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, UriTemplate = "single"

Reading HttpRequest Body in REST WCF

末鹿安然 提交于 2019-12-21 06:16:17
问题 I got a REST WCF Service running in .net 4 and I've tested the web service it is working and accepting HttpRequest I make to it. But I ran into a problem trying to access the HttpRequest body within the web service. I've tried sending random sizes of data appended on the HttpRequest using both Fiddler and my WinForm app and I can't seem to find any objects in runtime where I can find my request body is located. My initial instinct was to look in the HttpContext.Current.Request.InputStream but

Difference between wcf restful services and WEB API

风格不统一 提交于 2019-12-20 14:14:46
问题 I am query for a long time now.Where exactly we need to use WEB API and where should we use WCF restful services. What ever we want to achieve in WEB API we are able to achieve in WCF Rest. I tried to dig into answers but i got we need to do extra setting in wcf like URI templates,Contracts,endpoints. But its more on settings , but I wanted to known the real reason behind using WCF Restful Services. 回答1: Web Service It is based on SOAP and returns data in XML format. It supports only the HTTP

WCF The underlying connection was closed: An unexpected error occurred on a receive

我是研究僧i 提交于 2019-12-19 06:43:01
问题 I am using a RestClient app to communicate with my WCF service .and I am getting the following exception The underlying connection was closed: An unexpected error occurred on a receive. This is the C# code I use string q = string.Format(@"xxxxxxxxxxxxxxxxxxxxxxxxxxx"); WebClient client = new WebClient(); string Url = string.Format("{0}/Get?queries={1}", BaseUrl,HttpUtility.UrlEncodeUnicode(q)); client.Headers.Add(HttpRequestHeader.ContentType, "application/json"); var result = client

WCF The underlying connection was closed: An unexpected error occurred on a receive

偶尔善良 提交于 2019-12-19 06:41:12
问题 I am using a RestClient app to communicate with my WCF service .and I am getting the following exception The underlying connection was closed: An unexpected error occurred on a receive. This is the C# code I use string q = string.Format(@"xxxxxxxxxxxxxxxxxxxxxxxxxxx"); WebClient client = new WebClient(); string Url = string.Format("{0}/Get?queries={1}", BaseUrl,HttpUtility.UrlEncodeUnicode(q)); client.Headers.Add(HttpRequestHeader.ContentType, "application/json"); var result = client

WCF REST error HTTP 307

本秂侑毒 提交于 2019-12-19 03:36:36
问题 I have a REST WCF service. When a POST attempt is made to this service to an operation as mentioned below, I get the below error: [OperationContract] [WebInvoke(Method = "POST", UriTemplate = "", RequestFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Bare)] void Write(); Error: HTTP 307 There is no operation listening for https://xx.xxx.xx.xxx/EnrollmentServer/Discovery.svc, but there is an operation listening for https://xx.xxx.xx.xxx/EnrollmentServer/Discovery.svc/, so you

Transaction in REST WCF service

℡╲_俬逩灬. 提交于 2019-12-17 18:24:20
问题 We are having a REST WCF service. we want the save operation on this REST service to be in transaction. Is there a way to pass Transaction object over the wire to REST WCF service? 回答1: Here is a quote from Roy Fielding, the guy who invented the term REST If you find yourself in need of a distributed transaction protocol, then how can you possibly say that your architecture is based on REST? I simply cannot see how you can get from one situation (of using RESTful application state on the