Performance Comparison: SOAP vs. JSON (WCF-Implementation)

Damir Dobric Posts

Next talks:



Follow me on Twitter: #ddobric




As you probably know the JSON is more compact format than SOAP, which is very usable when you want to reduce the traffic on the network. To illustrate this, assume there is a class called Airport which looks like shown below:


When this class is serialized by using of DataContractSerializer the result is:

<a:Contact><a:FirstName>haso</a:FirstName><a:LastName>zgembic</a:LastName></a:Contact></a:Contacts ></a:Contact></a:Contacts><a:Latitude>-161.837997</a:Latitude><a:Longitude>60.779778</a:Longitude><a:Name>PABE</a:Name></a:Airport>

When using REST based service with JSON serialization (DataContractJsonSerializer) the instance of the airport-class sent over the network would look like:

My intension is not to describe in detail differences between this two formats, but it is obvious, that the JSON is much compacter.

When we now this, it reasonable to expect that the time needed for consuming of SOAP messages in comparison to JSON messages correlate to the amount of data. If you think this, you are wrong :)

Clearly it means: SOAP transmits 20-40% more data than JSON, but it is (in WCF) faster approximately 20-25% than JSON. How this is possible?  The reason is in WCF-JSON implementation itself. WCF internally serializes JSON streams to some kind of XML-Infoset wire format that requires about 50% more bytes than DataContractSerializer.

Comparison by time

Following diagram shows comparison between JSON and SOAP messaging in ten successively repeated tests. Values
in diagram are given in seconds for 3000 repeats per test. For example the first sample for JSON has taken 14 seconds and 10 seconds for SOAP each 3000 repeats. One repeat means send one request and receive response.
In this specific test we retrieved 101 instances of the class Airport (see below XML description of this type).


Exact values in seconds measured in this test ar given in the next table:

14 10
17 11
15 12
16 13
17 14
18 14
19 15
20 16
20 17
22 18


Comparison by network traffic

JSON (15862 bytes)


GET /GetJsonCoordinates.svc/GetCoordinates HTTP/1.1

Content-Type: application/xml; charset=utf-8

VsDebuggerCausalityData: uIDPo3f2jA1vh9tDhVf/HkaioegAAAAAjmFHoP+8OkyjmjyXSmDL4rwAh+pBIIdPmQ0493uxJYcACQAA

Host: dado-nb0:81

Connection: Keep-Alive


HTTP/1.1 200 OK

Content-Type: application/json; charset=utf-8

Server: Microsoft-IIS/7.0

X-Powered-By: ASP.NET

Date: Fri, 26 Dec 2008 23:13:23 GMT

Content-Length: 15852



 Note: Response not complete!

SOAP (31872 bytes)


POST /GetSoapCoordinates.svc HTTP/1.1

Content-Type: text/xml; charset=utf-8

VsDebuggerCausalityData: uIDPo3j2jA1vh9tDhVf/HkaioegAAAAAjmFHoP+8OkyjmjyXSmDL4rwAh+pBIIdPmQ0493uxJYcACQAA

SOAPAction: ""

Host: dado-nb0:81

Content-Length: 203

Expect: 100-continue

Connection: Keep-Alive


<s:Envelope xmlns:s=""><s:Body><GetCoordinates xmlns=""><area>GER</area><numOfRecords>100</numOfRecords></GetCoordinates></s:Body></s:Envelope>


HTTP/1.1 200 OK

Content-Type: text/xml; charset=utf-8

Server: Microsoft-IIS/7.0

X-Powered-By: ASP.NET

Date: Fri, 26 Dec 2008 23:15:44 GMT

Content-Length: 31872


<s:Envelope xmlns:s=""><s:Body><GetCoordinatesResponse xmlns=""><GetCoordinatesResult xmlns:a="" xmlns:i="">
<a:Airport><a:Contacts><a:Contact><a:FirstName>huso</a:FirstName><a:LastName>djimbilic</a:LastName></a:Contact><a:Contact><a:FirstName>haso</a:FirstName><a:LastName>zgembic</a:LastName></a:Contact></a:Contacts ></a:Contact></a:Contacts><a:Latitude>-161.837997</a:Latitude><a:Longitude>60.779778</a:Longitude><a:Name>PABE</a:Name></a:Airport></GetCoordinatesResult></GetCoordinatesResponse></s:Body></s:Envelope>

Note: Response not complete!

Posted Dec 27 2008, 03:49 PM by Damir Dobric
Filed under:


AS wrote re: Performance Comparison: SOAP vs. JSON (WCF-Implementation)
on 05-05-2009 6:58

interesting- does this mean that even though Json can be lightweight - using it with WCF - its actually going to be slower ?

Damir Dobric wrote re: Performance Comparison: SOAP vs. JSON (WCF-Implementation)
on 05-05-2009 9:47

Actually your statement is true. Personaly I think this might be changed in the near future.

geff zhang wrote JSON 和 JSONP
on 12-13-2009 13:43


王洋洋 wrote re: Performance Comparison: SOAP vs. JSON (WCF-Implementation)
on 02-07-2010 9:26


Shirley wrote re: Performance Comparison: SOAP vs. JSON (WCF-Implementation)
on 05-11-2010 18:39

This is hardly a valid comparison between JSON and SOAP.

What the data really says is that WCF is even worse on JSON than it is on SOAP.

Does making anything look this bad and/or work this poorly indicate lack of skill or questionable goals. (WCF, *not* the author)

manish wrote re: Performance Comparison: SOAP vs. JSON (WCF-Implementation)
on 07-01-2010 9:07

now I am  really confused!

anoynymous wrote re: Performance Comparison: SOAP vs. JSON (WCF-Implementation)
on 07-02-2011 21:55

how about compression? is a .Net Community Blog powered by daenet GmbH.