Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

REST in WCF for non dot.NET clients

I've read quite a few articles regarding the differences between REST and SOAP. I will just summarize in a few lines, please let me know if its wrong.

  1. SOAP is a protocol which uses HTTP, TCP etc to transfer the messages but REST uses only HTTP to transfer messages.

  2. SOAP transfers the messages in XML format only but REST uses JSON or XML.

  3. REST doesn't involve the same traffic overhead as SOAP (as SOAP involves the complex XML WSDL generation).

I've read that WCF was developed to provide interoperability. I have developed REST services in .net and the client was a mobile device (not a .net client). This one I have tested and gone live as well.

Having said that, my question is ...

Has anyone developed basichttpbinding WCF service and provided this to a non .net client like Java, mobile devices etc to make it interoperable? Is it possible for non .net clients to consume WCF other than REST?

like image 759
user3119881 Avatar asked Dec 25 '13 14:12

user3119881


1 Answers

Yes, you can consume a WCF service with any kind of SOAP or REST client.

SOAP is a protocol which uses HTTP, TCP etc to transfer the messages but REST uses only HTTP to transfer messages.

This is too broad to answer with either Yes or No. Strictly related to your question, we have this characteristics for SOAP:

  • SOAP is a protocol;
  • SOAP messages can be sent over HTTP, TCP, SMTP etc (any protocol actually). SOAP is a messaging protocol used on top of another transport protocol;
  • most used protocols for SOAP are HTTP and HTTPS;

Now the characteristics for REST:

  • REST is an architectural style of building applications;
  • REST is not actually bound to the HTTP protocol, it can use any transport protocol;
  • Everybody does REST with HTTP and HTTPS;

SOAP transfers the messages in XML format only but REST uses JSON or XML.

SOAP can only send XML messages, it's part of the protocol. You actually need to use a specific format for the XML with Envelope, Header and Body tags.

REST is about representations of resources. The representation can have any structure and can be in any format, not just XML or JSON (although XML and JSON are the most used);

REST doesn't involve the same traffic overhead as SOAP (as SOAP involves the complex XML WSDL generation).

WSDL is not involved in the actual call of operations, it's something separate to describe the SOAP web service. REST has something similar (although not very used) called WADL. You need to marshall/unmarshall your data with both SOAP and REST so the overhead is most of the time not an issue (the SOAP envelope is not that big).

Has anyone developed basichttpbinding WCF service and provided this to a non .net client like Java, mobile devices etc to make it interoperable? Is it possible for non .net clients to consume WCF other than REST?

That's the idea with web services (SOAP or RESTful), to be called from any kind of clients. It's a method of communications between two machines. The implementation of the machines does not matter (Java, C#, PHP, Python etc).

WCF is a web service framework that can expose the service as both SOAP or REST API. It can be called from any kind of client.

like image 145
Bogdan Avatar answered Sep 24 '22 21:09

Bogdan