wcf-rest

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

此生再无相见时 提交于 2019-11-29 02:10:07
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. Read error: ssl=0x1211a88: I/O error during system call, Connection reset by peer javax.net.ssl

WCF REST Service Template 40(CS) Cross domain error

穿精又带淫゛_ 提交于 2019-11-28 12:40:37
Hi I have a WCF Rest service using ( WCF REST Service Template 40(CS)). I have managed to get it to return Json response. It is working fine when the project is run. But when I try to make a Ajaxcall to the service from the browser, I am getting Error: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://192.168.0.70:8001/Service/test . This can be fixed by moving the resource to the same domain or enabling CORS. And The Ajax call: $.ajax({ type: "POST", url: "http://192.168.0.70:8001/Service/test", contentType: "application/json; charset=utf-8",

JSON data returned from WCF service contains escape characters

主宰稳场 提交于 2019-11-28 02:10:53
I have a working WCF - WPF application working, however I'm looking for some optimization. Below is my code where a WCF restful service is exposing a JSON array, and a WPF UI is receiving it without any problem. WCF: public clsStatus[] GetAllStatus() { DataTable dt = new DataTable(); List<clsStatus> lstGetAllStatus = new List<clsStatus>(); try { dt = // My Data Table foreach (DataRow dr in dt.Rows) { dcStatus objGetAllStatus = new clsStatus(); objGetAllStatus.Id = Convert.ToInt32(dr["Id"]); objGetAllStatus.Status = dr["Status"].ToString(); lstGetAllStatus.Add(objGetAllStatus); } } return

WCF REST Service not visible in WCFTestClient

好久不见. 提交于 2019-11-27 22:07:57
问题 I have successfully configured 3 endpoints for my prototype service. The endpoints are basicHttpBinding, wsHttpBinding, and webHttpBinding. The only glitch I have at the moment is in the WCFTestClient. When I point it to my service it lists the first two, but not the webHttpBinding. I can test the REST endpoint through my browser and it works just fine. Here's my config: <system.serviceModel> <services> <service behaviorConfiguration="serviceBehaviour" name="VMDServices.VMDService"> <endpoint

Uploading an image using WCF RESTFul service full working example

荒凉一梦 提交于 2019-11-27 21:44:24
As part of a pretty large application I need to provide a REST Service that uploads an image. Since the whole application is .NET, I've been trying to find an working example of a WCF RESTFul Service that does that but couldn't (Which defines the whole configurations). There are handful of examples online but I couldn't (thanks to my lack of knowledge in WCF) make none of them work. (I keep getting exceptions thrown). I'll be happy to get linked to a working one. Please find a sample below: On Server: Interface: [WebInvoke] string PostImage(Stream stream); My Implementation class: public

JSON.NET Serializer for WCF REST Services

瘦欲@ 提交于 2019-11-27 08:57:56
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.Add(new IsoDateTimeConverter()); var config = HttpHostConfiguration.Create(); config.Configuration

WCF REST Service Template 40(CS) Cross domain error

白昼怎懂夜的黑 提交于 2019-11-27 07:04:52
问题 Hi I have a WCF Rest service using ( WCF REST Service Template 40(CS)). I have managed to get it to return Json response. It is working fine when the project is run. But when I try to make a Ajaxcall to the service from the browser, I am getting Error: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://192.168.0.70:8001/Service/test . This can be fixed by moving the resource to the same domain or enabling CORS. And The Ajax call: $.ajax({ type

Can we create custom HTTP Status codes?

点点圈 提交于 2019-11-27 06:08:27
I have a REST and WCF service and want to send a custom status code based on the operation. Example when some validation fails then i want to send HTTP 444 and when authorization fails i want to send HTTP 455 The question is how do we have it validated for both SOAP and REST web services. On the client how does the error code act because when you send a HTTP 400/500 from a WCF Service (using SOAP) an exception is throw on the client showing the status code. Now if i send a new custom status code how does the client handle this? ChrisNY Yes, as long as you respect the class -- that is, 2xx for

CORS Support within WCF REST Services

大兔子大兔子 提交于 2019-11-27 03:59:29
I have a WCF REST service hosted within a Windows service and I would like to send the Access-Control-Allow-Origin HTTP header (defined as part of CORS ) with every response. My attempted solution was to have something like the following within an IDispatchMessageInspector implementation: public void BeforeSendReply(ref Message reply, object correlationState) { var httpResponse = reply.Properties["httpResponse"] as HttpResponseMessageProperty; if (httpResponse != null) { // test of CORS httpResponse.Headers["Access-Control-Allow-Origin"] = "*"; } } Normally this would work, but unfortunately

Cannot set content-type to 'application/json' in jQuery.ajax

岁酱吖の 提交于 2019-11-27 02:39:25
When I have this code $.ajax({ type: 'POST', //contentType: "application/json", url: 'http://localhost:16329/Hello', data: { name: 'norm' }, dataType: 'json' }); in Fiddler I can see following raw request POST http://localhost:16329/Hello HTTP/1.1 Host: localhost:16329 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2 Accept: application/json, text/javascript, */*; q=0.01 Accept-Language: ru-ru,ru;q=0.8,en-us;q=0.5,en;q=0.3 Accept-Encoding: gzip, deflate Connection: keep-alive Content-Type: application/x-www-form-urlencoded; charset=UTF-8 Referer: http:/