Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET SOAP Web Service return JSON

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.

like image 730
himanshu Avatar asked Apr 16 '13 04:04

himanshu


People also ask

Can we return JSON from SOAP service?

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.

How do I return JSON from ASMX web service?

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; } });

Can SOAP Web services use JSON?

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.


1 Answers

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

like image 77
Sergey Avatar answered Sep 22 '22 12:09

Sergey