2

From yesterdays i have started learning java web services, have seen many blogs still confuse, about which service is best for practice. either SOAP or Rest? Please suggest me best service method for request and response.

Thank You.

KhAn SaAb
  • 5,248
  • 5
  • 31
  • 52

5 Answers5

1

There is no best, only choices. Choose the one that meets your needs and get on with it. Or simply pick one if you don't know what meets your needs.

REST is a style based on HTTP. It requires a level of knowledge that you probably don't have. I'd recommend starting with SOAP because it's so well supported with tools. Once you're comfortable, learn REST.

duffymo
  • 305,152
  • 44
  • 369
  • 561
1

I think this article could help you: When to use rest or soap.

Personally I always use SOAP because it uses XML to transport the information, and it is easy to understand the structure of the data you are using in the comunication. Rest hasn't exactly a format to read, so it makes the things more complex to understand.

If you are just starting to learn about Web services I think you should go with SOAP.

maqjav
  • 2,310
  • 3
  • 23
  • 35
0

Well, REST is more used than SOAP (something like 70% of the webservices, but I can't figure out where those figures come from). So if you want to be a professional developer, it may be more interesting to learn REST.

Fabinout
  • 878
  • 7
  • 25
0

This question has been asked multiple times on SO over the years. You can find answers at Main differences between SOAP and RESTful web services in java and WSDL vs REST Pros and Cons and Restful vs Other Web Services

Community
  • 1
  • 1
Rajesh J Advani
  • 5,585
  • 2
  • 23
  • 35
0

Best Answer I found on SO

Both methods are used by many of the large players. It's a matter of preference. My preference is REST because it's simpler to use and understand.

SOAP:

  • SOAP builds an XML protocol on top of HTTP or sometimes TCP/IP.
  • SOAP describes functions, and types of data.
  • SOAP is a successor of XML-RPC and is very similar, but describes a standard way to communicate.
  • Several programming languages have native support for SOAP, you typically feed it a web service URL and you can call its web service functions without the need of specific code.
  • Binary data that is sent must be encoded first into a format such as base64 encoded.
  • Has several protocols and technologies relating to it: WSDL, XSDs, SOAP, WS-Addressing

Representational state transfer (REST):

  • REST need not be over HTTP but most of my points below will have an HTTP bias.
  • REST is very lightweight, it says wait a minute, we don't need all of this complexity that SOAP created.
  • Typically uses normal HTTP methods instead of a big XML format describing everything. For example to obtain a resource you use HTTP GET, to put a resource on the server you use HTTP PUT. To delete a resource on the server you use HTTP DELETE.
  • REST is a very simple in that it uses HTTP GET, POST and PUT methods to update resources on the server.
  • REST typically is best used with Resource Oriented Architecture (ROA). In this mode of thinking everything is a resource, and you would operate on these resources.
  • As long as your programming language has an HTTP library, and most do, you can consume a REST HTTP protocol very easily.
  • Binary data or binary resources can simply be delivered upon their request.

There are endless debates on REST vs SOAP on google.

My favorite is this one.

Community
  • 1
  • 1
Zaheer Ahmed
  • 28,160
  • 11
  • 74
  • 110