wcf-rest

RESTful services: WCF versus ASP.NET MVC

大城市里の小女人 提交于 2019-12-03 09:52:45
A very common approach to implementing RESTful services is by utilizing ASP.NET MVC to do so over WCF. ASP.NET MVC has excellent RESTful support by via flexible URL routing and flexible HTTP Method mapping to controller actions. WCF 4.0 now has excellent support for implementing RESTful service also using the same ASP.NET routing mechanism as ASP.NET MVC. Question What are your experiences working with either of the 2 approaches to create RESTful services and pros and cons encountered? WCF services can be self-hosted. No IIS required. ASP.NET MVC is focused on delivering HTML, whereas the

Sending Post request to RESTful WCF with json

余生长醉 提交于 2019-12-03 08:22:16
I have tried every combination to send a request to send a POST request to RESTful WCF from jQuery. Can someone imitate and make it working. Code is here : http://pastebin.com/Ua97919C I am working with WCF from past 2 years, but every time i send a POST request it makes me struggle a lot. I am struggling to make it work from past 4 days and gone through atleast 35-40 posts. Eventually, this request would be sent from iPhone to WCF. When i check it with Fiddler the error mostly is: *The server encountered an error processing the request. The exception message is 'The incoming message has an

wcf REST Services and JQuery Ajax Post: Method not allowed

有些话、适合烂在心里 提交于 2019-12-03 03:51:21
Anyone knows what's wrong with this? I cant get the json response from my wcf rest service. Jquery $.ajax({ type: 'POST', url: "http://localhost:8090/UserService/ValidateUser", data: {username: 'newuser', password: 'pwd'}, contentType: "application/json; charset=utf-8", success: function(msg) { alert(msg); }, error: function(xhr, ajaxOptions, thrownError) { alert('error'); } }); Service [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)] public class UserService: IUserService {

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

我怕爱的太早我们不能终老 提交于 2019-12-01 04:09:54
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.DownloadString(Url); Console.WriteLine("======================output================================"); Console

WCF REST error HTTP 307

允我心安 提交于 2019-11-30 23:59:48
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 are being redirected there. Any pointers will be appreciated. Change your UriTemplate to "/" instead.

Difference between WebOperationContext.current and HttpContext.Current

江枫思渺然 提交于 2019-11-30 11:59:08
I develop web and mobile applications for my customers. In my current architecture, many resources are shared between the web access and mobile access. An aspx page can be shown on web and be called to a web view in a mobile app. My question is : What is the difference between WebOperationContext.Current and HttpContext.Current object? From my understanding it is the same object, but I noticed that WebOperationContext.Current is null in some cases and I don't understand why. WebOperationContext is typically used in a WCF REST method so that method can access the incoming request and outgoing

WCF strange behaviour

ε祈祈猫儿з 提交于 2019-11-30 09:44:19
问题 I got this when I consume a webservice: Operation 'Login' of contract 'IServices' specifies multiple request body parameters to be serialized without any wrapper elements. At most one body parameter can be serialized without wrapper elements. Either remove the extra body parameters or set the BodyStyle property on the WebGetAttribute/WebInvokeAttribute to Wrapped. I use interface look like : namespace DreamServices { // NOTE: You can use the "Rename" command on the "Refactor" menu to change

Difference between WebOperationContext.current and HttpContext.Current

随声附和 提交于 2019-11-29 17:36:07
问题 I develop web and mobile applications for my customers. In my current architecture, many resources are shared between the web access and mobile access. An aspx page can be shown on web and be called to a web view in a mobile app. My question is : What is the difference between WebOperationContext.Current and HttpContext.Current object? From my understanding it is the same object, but I noticed that WebOperationContext.Current is null in some cases and I don't understand why. 回答1:

WCF strange behaviour

谁都会走 提交于 2019-11-29 17:15:24
I got this when I consume a webservice: Operation 'Login' of contract 'IServices' specifies multiple request body parameters to be serialized without any wrapper elements. At most one body parameter can be serialized without wrapper elements. Either remove the extra body parameters or set the BodyStyle property on the WebGetAttribute/WebInvokeAttribute to Wrapped. I use interface look like : namespace DreamServices { // 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

WCF REST Service not visible in WCFTestClient

梦想的初衷 提交于 2019-11-29 03:24:23
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 binding="webHttpBinding" address="rest" behaviorConfiguration="webBehaviour" contract="VMDServices