wcf-rest

REST WCF Service - Consume QueryString Parameters

梦想与她 提交于 2020-01-05 07:57:30
问题 I have this REST WCF service. [WebInvoke(UriTemplate = "/GetNames/{Category}?order=asc", Method = "POST", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)] public List<Names> GetNames(string Category) { //Code to retrieve Names by category. } The Category parameter is mapped to {Category} in the Uri. But how can I map the order query string in the Uri to this method? Adding the order as a parameter method is not working. please help. thanks in advance. 回答1: Have

How to pass and consume a JSON parameter to/with RESTful WCF service?

断了今生、忘了曾经 提交于 2020-01-02 02:01:45
问题 I am a beginner at RESTful services. I need to create an interface where the client needs to pass up to 9 parameters. I would prefer to pass the parameters as a JSON object. For instance if my JSON is: '{ "age":100, "name":"foo", "messages":["msg 1","msg 2","msg 3"], "favoriteColor" : "blue", "petName" : "Godzilla", "IQ" : "QuiteLow" }' And if I need to execute a server side method below in the end: public Person FindPerson(Peron lookUpPerson) { Person found = null; // Implementation that

Get Client IP address using WCF 4.5 RemoteEndpointMessageProperty in load balancing situation

拥有回忆 提交于 2020-01-01 10:50:14
问题 I have hosted WCF 4.5 Restful service in IIS and I am trying to use RemoteEndpointMessageProperty to get the IP address of the client who consumes the service. Code 1: private string GetClientIP() { OperationContext context = OperationContext.Current; MessageProperties prop = context.IncomingMessageProperties; RemoteEndpointMessageProperty endpoint = prop[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty; string ip = endpoint.Address; return ip; } Code 2: private string

Get Client IP address using WCF 4.5 RemoteEndpointMessageProperty in load balancing situation

时光毁灭记忆、已成空白 提交于 2020-01-01 10:50:07
问题 I have hosted WCF 4.5 Restful service in IIS and I am trying to use RemoteEndpointMessageProperty to get the IP address of the client who consumes the service. Code 1: private string GetClientIP() { OperationContext context = OperationContext.Current; MessageProperties prop = context.IncomingMessageProperties; RemoteEndpointMessageProperty endpoint = prop[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty; string ip = endpoint.Address; return ip; } Code 2: private string

Intermittent Connection Reset by Peer errors in Android connecting to .NET REST endpoint

孤街浪徒 提交于 2019-12-29 05:25:54
问题 I'm getting intermittent errors from devices connecting to my IIS REST service via SSL. My app works just fine, but sometimes I get this exception. It is handled properly and does not bring down app.. ut I wonder what does it mean and if there any way to fix it? Currently it causes delays in data retreived. Also, it floods logs and I can't really ignore it.. I wonder if I can better this situation. Is this something I should expect when I deal with REST services? My server is on Amazon EC2.

JSON.NET Serializer for WCF REST Services

寵の児 提交于 2019-12-28 02:59:25
问题 I am trying to use the NETFx Json.NET MediaTypeFormatter nuget package to swap out the default DataContractJsonSerializer in my WCF REST service (4.0 framework). I downloaded the package in my project and added the following lines of code in the Global.asax file. void Application_Start(object sender, EventArgs e) { RegisterRoutes(); // Create Json.Net formatter serializing DateTime using the ISO 8601 format var serializerSettings = new JsonSerializerSettings(); serializerSettings.Converters

WCF REST to web API [closed]

北战南征 提交于 2019-12-25 08:55:55
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago . I want to migrate from wcf rest services to web API, (around 30 endpoints to be created with 6 complex methods) just want to decide based on the budget (1 month time with one resource) available, which amongst the below would be a better solution. Writing whole new code for

How To Return PDF/Binary Data From a Database In a WCF

爱⌒轻易说出口 提交于 2019-12-25 02:50:40
问题 I have a WCF-REST service that returns data in JSON format, that reads from a database in SQLSERVER... To return simple data, I don't have any problem. Now, I want to return,a PDF file, that is at the database in varbinary(max) field. What is the correct way to return the PDF data in a WCF Rest Service? [EDITED] This is how It was suggested. This is the class: [WebGet(UriTemplate = "/documents/{id}")] public ActionResult GetDocument(int id) { using (var context = new CorrespondenceDataContext

Why am I getting a “405 Method not allowed” error on “Put” operations through a WCF Resful service?

夙愿已清 提交于 2019-12-24 01:29:11
问题 I've got a simple WCF service which takes json as input/output parameters. It works correctly as a SOAP based service and I get the expected results. I have added RESTFul endpoints to the service. I'm using "Google-based" PostMan to test the service. I can successfully call "Get" methods on the service and return JSON results: [OperationContract(IsOneWay = false)] [WebGet(UriTemplate = "/Test/{calcID}", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)] CalcResults

HTML form POST to WCF service

余生颓废 提交于 2019-12-23 05:23:10
问题 Having trouble getting a WCF service to work with a HTML form post. I'm creating an SVGToPng service. The service accepts a String (SVG data) and converts it into an image to download (with save file dialogue). Right now all of the existing services are configured to use JSON as the message type. This particular method will be unique whereas I need to perform a good-old-fashioned form POST. Here's the interface for the service. [OperationContract] [WebInvoke(Method = "POST", UriTemplate =