I'm not here to teach anyone to write a SOAP Web Service or a REST API. And I don't own the truth, I'm just exposing my own opinion based on my experience.
The Concept
In a simple way to understand the concept, we can assume Web Services as pieces of software running under a application server, responsible for synchronous communication.Along with JMS, it's heavily used on systems integration. One thing that must be clear is that Web Services and SOA are not the same thing. SOA is the architecture that makes use of services. And these services can or cannot be web services. The umbrella for services on the SOA concept is wider than the single idea of a web service.
SOAP x REST API
When we talk about web services, we always gets into a discussion about SOAP Web Services versus the REST API, their differences, and when to adopt each one.When we read and learn about SOAP, the UDDI is always mentioned. UDDI can be seen as a catalog of web services. But I've never seen an UDDI fully implemented and in use.
The Java specification in this case is the JAX-WS - JSR 224.
The Java specification in this case is the JAX-RS - JSR 339.
When to use them? Some may say it's a really abstract question, since both can solve the same problems. But you can find some differences when you think about their nature. Imagine a Bank, that needs to be integrated to external companies. The systems are exposed to their partners as web services. In this scenario, it's interesting to have a well defined document/contract for the communication, to make sure the correct information is being sent/received. I believe that's the reason SOAP the most used protocol on the integration scenarios. Even though you can use REST with a XML being communicated and validated agains an XSD, for example, on SOAP, this contract is more consistent.
In another hand, for a product developed by one company, exposed over the internet, it will make calls to their own systems. Lighter and with higher performance, REST looks like to be the best option on this scenario.
Some Testing Tools
soapUIcURL