When to use DataContract and DataMember attributes?

I am very confused about the DataContract attribute in WCF. As per my knowledge it is used for serializating user defined type like classes. I wrote one class which is exposed at client side like this. [DataContract] public class Contact { [DataMember] public int Roll { get; set; } [DataMember] public string Name { get; … Read more

HTTP could not register URL http://+:8000/HelloWCF/. Your process does not have access rights to this namespace

I’m a beginner in WCF, but trying to improve my experience. And on the first step I faced the problem. I created the simplest WCF service. The listing of code: (all the code in one file) using System; using System.ServiceModel; namespace EssentialWCF { [ServiceContract] public interface IStockService { [OperationContract] double GetPrice(string ticker); } public class … Read more

How do I return clean JSON from a WCF Service?

I am trying to return some JSON from a WCF service. This service simply returns some content from my database. I can get the data. However, I am concerned about the format of my JSON. Currently, the JSON that gets returned is formatted like this: {“d”:”[{\”Age\”:35,\”FirstName\”:\”Peyton\”,\”LastName\”:\”Manning\”},{\”Age\”:31,\”FirstName\”:\”Drew\”,\”LastName\”:\”Brees\”},{\”Age\”:29,\”FirstName\”:\”Tony\”,\”LastName\”:\”Romo\”}]”} In reality, I would like my JSON to be … Read more

Could not find default endpoint element

I’ve added a proxy to a webservice to a VS2008/.NET 3.5 solution. When constructing the client .NET throws this error: Could not find default endpoint element that references contract ‘IMySOAPWebService’ in the ServiceModel client configuration section. This might be because no configuaration file was found for your application or because no endpoint element matching this … Read more

Best Practices for securing a REST API / web service [closed]

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 4 years ago. Improve this question When designing a REST API or service are there any established best practices for dealing with … Read more