Web Services (SOAP, REST) FOR restful api code example
Example: Difference between SOAP and RESTful web services
RESTful:
- is architectural style
- stateless
- requires HTTP
- supports JSON, XML, HTML, CSV, plain text
- easy documentation and easy to understand
- efficient and faster
- less bandwidth
- less secure
- Uses JAX-RS API for security
SOAP:
- ss XML based protocol itself
- State or stateless
- Can work with HTTP, SMPT(Simple Mailing Transfer Protocol),
FTP(File Transfer Protocol)
- Only works with XML
- Documentation is complex and hard to understand
- Slower than REST
- More secure
- Uses JAX-WS API for security
- Platform and programming language independent
REST-Assured library helps us in testing our RESTful APIs easily.
It integrates seamlessly with TestNG and JUnit. JSON Path and XML Path
allows us to easily parse the response data and test specific elements.
Since it uses Hamcrest matchers, there are many options to match actual
result with expected data.