WCF as a web service with the least possible load

These days, I have spent most of my work with Microsoft technologies, so naturally I check what WCF has to offer. It seems like a very flexible and great addition to removing .Net, but it seems to be very attached to SOAP messages and quite awkward for the platform's agnostic web service application. I am not a specialist in this technology, but I believe that all the flexibility they advertise means you can tear yourself away from SOAP messages and return any data structures and format. Is this true or false?

The reason I'm talking is because if I really wanted to create the application as a REST service, one of my target platforms would be mobile. Not only one important goal of any web service is to preserve the payload of data, whether it’s mobile at dialing speed or a full desktop application.

So, if you take the Twitter api as an example, it was incredibly successful because you can request data as JSON without any fancy SOAP envelopes weighing the data and receiving the least number of bytes to represent the required data. Thus, a mobile application running on a poorly connected device that uses Twitter data can use minimal bandwidth. In addition, the Twitter, Facebook template, or any of the more successful public api is a custom data structure in JSON and / or XML and not wrapped in a SOAP envelope (although I could be wrong ... this is just my impression).

How do you do this in WCF? Do you need to jump over hoops to tell WCF "just return this text ... don't worry about a SOAP envelope", or is this a simple configuration option?

+4
source share
3 answers

See WCF RESTful POX, JSON, and SOAP Coexist . It is actually very simple to configure WCF to return simple POX and / or JSON.

+2
source

There are several configuration options that you can set to remove SOAP from WCF. The simplest thing is to use WebServiceHost, not the regular ServiceHost class to host your services. It sets most of the options you want. Justin Smith has a good post that contrasts with WebServiceHost and ServiceHost .

Although it seems that you are more worried about sending useful POX (plain old XML) information that some of the principles of REST (URL mapping and HTTP methods) are, you can find Jon Flander RESTful.NET to help. Here is an overview of chapter 1 .

Also check out Microsoft's REST Starter Kit , which has many examples of how to do common web-based tasks with WCF.

And to answer another part of your question, I found that using JSON leads to a much lower load than XML, but it has decent support in WCF.

+2
source

All Articles