I need to prepare a .Net SOAP Web Service which returns JSON format, we have to use those service in iPad & Android.
I searched a lot but found only WCF Restful service that return JSON and ASMX SOAP service that return XML.
Please help me to prepare a .Net SOAP web service which returns JSON data either WCF or ASMX (WCF recommended).
If possible please also let me know what is the standard format (WCF REST return JSON, WCF SOAP return JSON, ASMX SOAP return XML, etc.) to use .NET web-services with iPad/iPhone & Android.
SOAP relies exclusively on XML to provide messaging services, so if you really want/need to return JSON then you would need to wrap it in CDATA in the SOAP XML body. Unlike SOAP, however, REST does not have to use XML to provide the response, therefore you can output the data in other formats such as JSON.
For example you can use below code (if you are using jquery) instead of changing somethings in WebService: $. ajax({ type: "POST", url: '/ServiceName. asmx/WebMethodName', date: {}, contentType: "application/json; charset=utf-8", success: function (data) { // Some code; } });
SOAP web services are described using WSDL documents. JSON web services are structured less formally; they tend to be loosely coupled and prefer documentation by example. SOAP web services have an explicit error format involving SOAP Fault messages. There's no equivalent for JSON.
Using WCF it is trivial to return JSON, and IOS developers will love you if you avoid SOAP. Since you didn't specify a version of .NET you require, I will point you to the latest and greatest feature called Web API. See the tutorial here http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/tutorial-your-first-web-api
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With