locked
WCF & JSON RRS feed

  • Question

  • User-221752185 posted

    I have a WCF that was built using .NET 3.5 Currently it uses basicHttpBinding over SSL w/ SOAP.

    I need to change the format from SOAP to JSON. But I have no idea how to do this. Can someone please tell me what configuration or contract adjustments I need to make :) Should be simple/quick enough right?

    Friday, July 12, 2013 10:25 AM

Answers

  • User220959680 posted

    change the format from SOAP to JSON

    SOAP is a protocol i.e., Simple Object Access Protocol.   Json is data format that is returned by the web service. Json stands for 'JavaScript Object Notation'.

    To spit out Json formatted data expose your service as REST.

    Refer http://www.dotnetcurry.com/ShowArticle.aspx?ID=728

    //Note that it is required to replace //WebMessageFormat.Xml to Json
    
    [WebGet(UriTemplate="/Employees", ResponseFormat=WebMessageFormat.Json)]
    



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 12, 2013 11:44 AM

All replies

  • User220959680 posted

    change the format from SOAP to JSON

    SOAP is a protocol i.e., Simple Object Access Protocol.   Json is data format that is returned by the web service. Json stands for 'JavaScript Object Notation'.

    To spit out Json formatted data expose your service as REST.

    Refer http://www.dotnetcurry.com/ShowArticle.aspx?ID=728

    //Note that it is required to replace //WebMessageFormat.Xml to Json
    
    [WebGet(UriTemplate="/Employees", ResponseFormat=WebMessageFormat.Json)]
    



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 12, 2013 11:44 AM
  • User-221752185 posted

    Your example is specifically 4.0 I was clear in my question that I am running 3.5. Also, Is there a way to do it without having to change the WCF as a REST Service? If it is REST, can the developer still generate a proxy from it like normal?

    Friday, July 12, 2013 12:23 PM
  • User220959680 posted

    Your example is specifically 4.0 I was clear in my question that I am running 3.5.

    Reference works with 3.5 as well.

    Is there a way to do it without having to change the WCF as a REST Service?

    feasible. Refer http://stackoverflow.com/questions/5752975/wcf-service-method-to-return-json-or-soap

    If it is REST, can the developer still generate a proxy from it like normal?

    For REST service proxy is not required to interact with the service. Client can invoke the service directly through URI i.e., Service URL. 

    Monday, July 15, 2013 7:23 AM