0

I'm confused , very .

I'm reading a bunch of articles and SO posts on WCF & SOAP & REST , but I'm still confusing everything regarding the communication between a client and WCF server .

When I'm doing something like this :

  [ServiceContract]
    public interface IGeoService
    {
        [OperationContract]
        ZipCodeData GetZipInfo(string zip);

        [OperationContract]
        IEnumerable<string> GetStates(bool primaryOnly);

        [OperationContract(Name = "GetZipsByState")]
        IEnumerable<ZipCodeData> GetZips(string state);

        [OperationContract(Name = "GetZipsForRange")]
        IEnumerable<ZipCodeData> GetZips(string zip, int range);
    }

I'm making a contract , right ?

Then when one of those methods is requested from a WCF client , what exactly is the return value from the WCF server ? is it a JSON , or an XML ?

Thanks

JAN
  • 21,236
  • 66
  • 181
  • 318
  • 1
    Depends on how you configure it. Note a duplicate, but this question: http://stackoverflow.com/questions/2086666/how-do-i-return-clean-json-from-a-wcf-service has an example of outputting JSON – Rob Jan 06 '16 at 05:45
  • As mentioned above, it depends upon what response your client needs or is expecting from WCG service. – Swanand Pangam Jan 06 '16 at 05:58
  • @SwanandPangam: OK , So when I'm using XML I'm actually using SOAP , and when I'm using JSON I'm using REST ? – JAN Jan 06 '16 at 05:59
  • @ron not exactly. In my honest opinion, wcf when called by a web client becomes RESTful or else its SOAP. – Swanand Pangam Jan 06 '16 at 06:08
  • By Default WCF project, if you don't specifically configure anything, it will return xml by default. – TNA Jan 06 '16 at 08:08
  • Save yourself a world of headaches and use [Servicestack.net](https://servicestack.net/) instead of WCF. You can try their free one at the bottom of their downloads page if your budget is low. It works, I've used it several times. – Chuck Savage Jan 06 '16 at 10:05

0 Answers0