Sunday, December 26, 2021

Performance Engineering Articles

General Performance Engineering:
  • Performance Testing To Performance Engineering
  • Tips to become a good Performance Engineer
  • Performance Engineering Basics
  • Architectural Understanding
  • Identification of Performance Bottleneck
  • Performance Bottleneck Identification
  • Beyond Performance Testing
  • Capacity Planning
  • Physical CPU vs Logical CPU
  • Impact of Cache on Application Performance
  • Response Time improvement from 10 to 1 to 0.1
  • How does HTTP protocol work?
  • Server Timing
  • JVM Basics and Performance Solutions
  • Apache Kafka - Monitoring and Performance Tuning
  • Server Side Performance Monitoring - Issues, Solutions and Tools
  • How to reduce Page Load time?
  • Memory Leakage - Types, Reasons and Resolutions
  • Performance Engineering with DevOps Methodology
  • Reasons for High CPU usage
  • True causes of Performance Bottlenecks
  • CPU Bottleneck Identification
  • MySQL Performance Issue
Tuning Tips:
  • MySQL Tuning
  • Java Performance Tuning Tips
  • Java Performance Issues and Resolutions
  • Heap Dump and Thread Dump Analysis
  • Calculation of Shallow Heap and Retained Heap Size
Garbage Collection (GC) Analysis:
  • Why GC log analysis is required?
  • Importance of GC
  • Myths and Truths of GC
  • GC Duration vs GC Pause Duration
Thread Dump Analysis:
  • Heap Dump and Thread Dump Analysis
  • Thread Dump Analysis - Athlete Pattern
  • Thread Dump Analysis - Atherosclerosis Pattern
  • Thread Dump Analysis - All Roads Lead to Rome Pattern
  • Thread Dump Analysis - Traffic Jam Pattern
  • Thread Dump Analysis - TreadMill Pattern
  • Thread Dump Analysis - RSI
  • Thread Dump Analysis - Stock Ticker
  • Thread Dump Analysis - Additives
  • Thread Dump Analysis - Several Scavengers
Case Studies:
  • A performance improvement case study
  • A case study of Performance Tuning
  • DynaTrace Features - Case Study

Friday, December 24, 2021

Page Load Time

What is Page Load Time in Performance Testing?
Def :  ‘Response Time refers to the amount of time from the moment that a user sends a request until the time that the application indicates that the request has completed and reaches back to the user.’ 
Page Rendering Time :- Total time is taking to get the immediate next page.
There are no tools that can provide you client-side rendering times. Client side rendering is not a measurable value,
Page Load Time : How much time it is taking the page to load all the content in the page.. Also, we can say that it is a time when all the components (items) of a page get displayed on the browser for user interaction. It depends on 3 things:

Server Processing Time: How quickly the servers serve the request and send response back to the client.
Network Latency: How quickly the communication channel transfer the information from client to server and server to client.
Component Load Time: How quickly it takes for the browser to parse and execute the document (available in cache or coming from server) and render the page to make it available for user interaction.
Let’s try to understand the terms with the given figure:

Figure 01
  1. User enters a URL, submits a form, or clicks on a hyperlink
  2. Browser makes a request to the server through the network
  3. Server processes the request
  4. Server sends the response back to the browser
  5. At client end, browser starts receiving the requested page and related information
  6. Browser fetches the stored cache components
  7. Browser parses, loads, and renders the page content
  8. The entire requested page becomes available on the browser
How to improve it?
Following are the common methods to improve the Page Load Time:
  • Reduces the size of the CSS, HTML, JavaScript, images, and other web elements
  • Optimizes the code by removing unused code, white spaces, comments, etc.
  • Reduce the redirects
  • Fast Network
How to Improve Your Page Load Time
Here are 10 quick tips aimed at optimizing your website’s loading time:
1. Optimize Image Size and Format
The images on your site can take up a lot of bandwidth, which affects the loading time of your page. It is not enough to downsize your website’s images in HTML because that only changes the appearance of the image and not its actual size. Use external picture editor tools to resize the images, such as Photoshop and set them to 72dpi.
Additionally, use image optimization tools which further compress the image to reduce its size:

JPEG & PNG Stripper
Smush.it
Online Image Optimizer
SuperGIF
For optimized loading time of your page it is ideal to stick to standard image formats such as JPG, PNG and GIF.
2. Optimize Dependencies
Plugins: A site that requires plugins may slow your page loading speed. Not all plugins are unnecessary; for example, social share plugins which are a must-have for every site these days. That said, always check to see if there is a better alternative to the plugin, such as using a CMS with built-in social plugins.

Tracking Scripts: While it is wise to keep tabs on your website’s traffic stats, it is not advisable to use multiple tracking softwares as this may hinder the page load time. If you are using a CMS such as WordPress, you should allow either WP stats to run scripts on your page or Google Analytics, but not both.

CMS Software: If you are using a CMS such as WordPress it is recommended to check frequently for updates in the software but do not load these on a live website. First carry out upgrades on a separate server to test them. Keeping abreast of software updates also improves a site’s speed.
3. Avoid Inline JS and CSS files
It is a good practice to place your website’s JS and CSS in external files. When the page loads the browser caches these files externally and reduces the page load time on subsequent requests. Moreover, having the JS and CSS files externally allows for easier site maintenance.
4. Optimize Caching
Every time a visitor loads a site, your web page’s image files, CSS and Java files load as well, taking up a lot of page load time. When caching is set up correctly, your browser can store these resources or files for subsequent requests. On repeated page loads these files can be retrieved from the cache rather than downloading them all over again from the network. This also reduces bandwidth and hosting costs.

You can use Expires headers for static components of the site and Cache-Control headers for dynamic ones. Using these headers makes the various components of a site, including images, stylesheets, scripts and flash, cacheable. This in turn minimizes HTTP requests and thus improves the page load time. With the use of Expires headers you can actually control the length of time that components of a web page can be cached, as shown in the example below:
Expires: Wed, 20 Apr 2015 20:00:00 GMT

If your server is Apache you can set the time for cached content by using the ExpiresDefault directive. This sets the expiration date as a certain number of years from the current date:
ExpiresDefault “access plus 15 years”
5. Avoid render blocking scripts
Place javascript files at the end of the body or use the 'async' attribute to load them asynchronously.
6. Avoid Redirects
Avoiding redirects increases serving speed. Some redirects are unavoidable and need to be in place but you must remember that this requires an additional HTTP which increases the page load time. Check for broken links and fix them immediately.
7. Set up G-Zip Encoding
Similar to files on your PC that are zipped and compressed to reduce the total size during online file transfers, heavy files on your website can be zipped with something called the G-Zip Compression. This saves bandwidth and download time and reduces your page loading speed. You should configure the server so that it returns zipped content.
8. Reduce HTTP Requests
Use CSS Sprites to reduce the number of image requests. Combine background images into a single image by using CSS background-image and background-position elements. Combine inline images into your cached stylesheets. Likewise, combine all your javascript files into a single file and all your CSS files as well.
9. Minification of JavaScript and CSS
Minification is the process of compressing the code by renaming variables to shorter names which helps to reduce its size and the subsequent loading time. We recommend using uglify.js for this.
10. Reduce Cookie Size
Cookies are used to store data that needs to persist between requests. This data is sent on every request and adds to the load time when it’s big. Hence, by reducing the size of the cookies you reduce the size of the data that is transferred and decrease the page load time. Eliminate unnecessary cookies or reduce the size of the cookies.

SPEED INDEX

Speed Index (SI) is a UI Performance Testing metric that calculates how quickly the content of the webpage is visually displayed to the end-users. Actually, the speed index is not a time-based unit. It is a score that represents the content loading speed of a web page. The lesser is the value of SI, the better is the performance of that website.

How to calculate Speed Index?
The calculation of the speed index is pretty simple but it depends on the UI tool what time interval is considered to capture the visual frames. The UI tool calculates what percent of the page is visually completed at a fixed time interval until the page is visually completed.

Let’s try to understand Speed Index calculation with an example. Refer to the below figure that shows 5 frames of a website. The UI tool captures the loading screen of the website at a fixed interval (i.e. 500 ms) and calculates the percentage of visual completeness at that moment by some internal logic.
















The formula of the speed index is

Speed Index - Formula
Now, put the values in the above formula:
500 * (1-(0/100)) = 500
500 * (1-(10/100)) = 450
500 * (1-(40/100)) = 300
500 * (1-(60/100)) = 200
500 * (1-(100/100)) = 0

Speed Index = 500 + 450 + 300 + 200 + 0
Speed Index = 1450

What is the ideal value of SI?
As described above, UI tools take different time interval frames to calculate the SI. Hence the value range is also different. Speed Index standard as per Google Lighthouse is:

Speed Index (in milliseconds) Considered As             Colour Coding
0 to 3400                                         Fast                             Green
3400 to 5800                                 Moderate                     Orange
Over 5800                                      Slow                             Red
Table 01
 Some tools consider less than 1000 as a good SI score. So, again it depends on the approach of the calculation.

How to improve Speed Index score?
SI score can be improved by applying the following solutions:
  1. Optimize JavaScript and reduce the execution time
  2. Remove unused JavaScript
  3. Use lazy loading image
  4. Use progressive image logic
  5. Create Cache Hierarchy
  6. Optimize Images and Font
Can SI value be False?
Yes, consider there are two websites with the following visual completeness values:

Time Interval (in ms) VC of Website A     VC of Website B
0                                 0%                              0%
500                                 10%                            5%
1000                                30%                            10%
1500                                60%                            90%
2000                                100%                          100%
SI Score                          1500                            1475
Table 02
Since the full content of both the websites is loaded at the same time (i.e. at t=2000ms) and visually ready for the users so which website is faster than the other one?

The SI score of Website A is 1500 and Website B is 1475. Perhaps you would say Website B is faster than Website A on the basis of SI score but this is not completely true. Because the user will feel Website A is faster due to its gradual progressive nature whereas Website B will load most of the content suddenly at the last moment.

SI is always considered a subjective and supportive metric instead of a conclusive metric. Only SI metric is not enough to tell whether a website is slow or fast. Along with the Speed Index, you also need to consider other UI Performance metrics like First Contentful Paint, Largest Contentful Paint etc.

Wednesday, December 22, 2021

API Testing

1. What is an API?
An API (Application Programming Interface) is a software intermediary that enables two applications to communicate with each other. It comprises a number of subroutine definitions, logs, and tools for creating application software.
Examples, here are the well-known ones: Google Maps API, Amazon Advertising API, Twitter API, YouTube API, etc.
2. What are main differences between API and Web Service?
All Web services are APIs but not all APIs are Web services.
Web services might not contain all the specifications and cannot perform all the tasks that APIs would perform.
A Web service uses only three styles of use: SOAP, REST and XML-RPC for communication whereas API may be exposed to in multiple ways.
A Web service always needs a network to operate while APIs don’t need a network for operation.
3. What are the Limits of API Usage?
Many APIs have a certain limit set up by the provider. Thus, try to estimate your usage and understand how that will impact the overall cost of the offering. Whether this will be a problem depends in large part on how data is leveraged. Getting caught by a quota and effectively cut-off because of budget limitations will render the service (and any system or process depending on it) virtually useless.
Creating an API 
4. What are some architectural styles for creating a Web API?
Bellows are four common Web API architectural styles:
HTTP for client-server communication
XML/JSON as formatting language
Simple URI as the address for the services
Stateless communication
5. Who can use a Web API?
Web API can be consumed by any clients which support HTTP verbs such as GET, PUT, DELETE, POST. Since Web API services do not require configuration, they can be easily used by any client. In fact, even portable devices such as mobile devices can easily use Web API, which is undoubtedly the biggest advantage of this technology.
Testing an API
6. What is API Testing?
API testing is a kind of software testing that determines if the developed APIs meet expectations regarding the functionality, reliability, performance, and security of the application.
7. What are the advantages of API Testing?  
Test for Core Functionality: API testing provides access to the application without a user interface. The core and code-level of functionalities of the application will be tested and evaluated early before the GUI tests. This will help detect the minor issues which can become bigger during the GUI testing.
Time Effective: API testing usually is less time consuming than functional GUI testing. The web elements in GUI testing must be polled, which makes the testing process slower. Particularly, API test automation requires less code so it can provide better and faster test coverage compared to GUI test automation. These will result in the cost saving for the testing project.
Language-Independent: In API testing, data is exchanged using XML or JSON. These transfer modes are completely language-independent, allowing users to select any code language when adopting automation testing services for the project.
Easy Integration with GUI: API tests enable highly integrable tests, which is particularly useful if you want to perform functional GUI tests after API testing. For instance, simple integration would allow new user accounts to be created within the application before a GUI test started.
8. Some common protocols used in API testing?
Many protocols are now available to be used in API testing, such as JMS, REST, HTTP, UDDI and SOAP.
9. What is the test environment of API?
The test environment of API is a bit complete and requires the configuration of the database and server, depending on the software requirements. No GUI (Graphical User Interface) is available in this test form.
When the installation process is complete, API is verified for the proper operation. Throughout the process, the API called from the original environment is set up with different parameters to study the test results.  
10. What are principles of an API test design?
The five most important principles of an API test design are:
Setup: Create objects, start services, initialize data, etc
Execution: Steps to apply API or the scenario, including logging
Verification: Oracles to evaluate the result of the execution
Reporting: Pass, failed or blocked
Clean up: Pre-test state
11. What are the common API testing types?
While there are certainly specialty tests, and no list can be asked to be comprehensive in this realm, most tests fit broadly into these following nine categories.

Validation Testing
Functional Testing
UI testing
Load testing
Runtime/ Error Detection
Security testing
Penetration testing
Fuzz testing
Interoperability and WS Compliance testing
12. What is the procedure to perform API testing?
Choose the suite to add the API test case
Choose the test development mode
Demand the development of test cases for the required API methods
Configure the control parameters of the application and then test conditions
Configure method validation
Execute the API test
Check test reports and filter API test cases
Arrange all API test cases
13. What must be checked when performing API testing?
During the API testing process, a request is raised to the API with the known data. This way you can analyze the validation response. While testing an API, you should consider:
Accuracy of data
Schema validation
HTTP status codes
Data type, validations, order and completeness
Authorization checks
Implementation of response timeout
Error codes in case API returns, and
Non-functional testing like performance and security testing
14. What is the best approach method to perform API testing?
The following factors should be considered when performing API testing:

Defining the correct input parameters
Verifying the calls of the mixture of two or more added value parameters
Defining the basic functionality and scope of the API program
Writing appropriate API test cases and making use of testing techniques such as equivalence class, boundary value, etc. to check the operability
Testing case execution
Comparing the test result with the expected result
Verifying the API behavior under conditions such as connection to files and so on.
15. What are tools could be used for API testing?
There are myriad of different API testing tools available. A few of common tools are Katalon Studio, Postman, SoapUi Pro, Apigee, etc.  While doing Unit and API testing, both targets source code. If an API method uses code based in .NET then another supporting tool must have .NET.
16. What are differences between API Testing and Unit Testing?
api testing vs unit testing
17. What are differences between API Testing and UI Testing?
API enables communication between two separate software systems. A software system implementing an API contains functions or subroutines that can be executed by another software system.
On the other hand, UI ( User Interface) testing refers to testing graphical interface such as how users interact with the applications, testing application elements like fonts, images, layouts etc. UI testing basically focuses on look and feel of an application.
18. What are major challenges faced in API testing?
If you can overcome the challenges in API Testing, They are:

Parameter Selection
Parameter Combination
Call sequencing
Output verification and validation

Another important challenge is providing input values, which is very difficult as GUI is not available in this case.
19. What are the testing methods that come under API testing?
Testing methods. They are:

Unit testing and Functional testing
Load testing to test the performance under load
Discovery testing to list, create and delete the number of calls documented in API
Usability and Reliability testing to get consistent results
Security and Penetration testing to validate all types of authentication
Automation testing to create and run scripts that require regular API calls
End to end Integration and Web UI testing
API documentation testing to determine its efficiency and effectiveness
20. Why is API testing considered as the most suitable form for Automation testing?
API testing is now preferred over GUI testing and is considered as most suitable because:

It verifies all the functional paths of the system under test very effectively.
It provides the most stable interface.
It is easier to maintain and provides fast feedback.
21. What are common API errors that often founded?
Missing module errors
Documentation errors
Parameter validation errors
And some standard error expectations as if the result is not so predicted then the occurrence of errors can be seen and for the same warnings are specified in the form of a message. There can be one or more warnings within an individual module.
22. What kinds of bugs that API testing would often find?
Missing or duplicate functionality
Fails to handle error conditions gracefully
Stress
Reliability
Security
Unused flags
Not implemented errors
Inconsistent error handling
Performance
Multi-threading issues
Improper errors
Documenting the API
23. What is API documentation?
The API documentation is a complete, accurate technical writing giving instructions on how to effectively use and integrate with an API. It is a compact reference manual that has all the information needed to work with the API, and helps you answer all the API testing questions with details on functions, classes, return types, arguments, and also examples and tutorials.

24. What are API documentation templates that are commonly used?
There are several available API documentation templates help to make the entire process simple and straightforward, such as:

Swagger
Miredot
Slate
FlatDoc
API blueprint
RestDoc
Web service API specification
25. When writing API document, what must be considered?
Source of the content
Document plan or sketch
Delivery layout
Information needed for every function in the document
Automatic document creation programs
26. How often are the APIs changed and, more importantly, deprecated?
APIs, especially modern RESTful APIs, are a nice creation that can certainly simplify and accelerate integration efforts, which makes it more likely you will benefit from them. But APIs can and do change for various reasons, sometimes abruptly, and hence REST APIs do not differ from traditional integration methods in this respect. If an API call is obsolete and disappears, your procedure will interrupt and it is important to understand how often the APIs you depend on change or are deprecated.

 REST
27. What is REST?
REST (Representational State Transfer) is an architectural style for developing web services which exploit the ubiquity of HTTP protocol and uses HTTP method to define actions. It revolves around resource where every component being a resource that can be accessed through a shared interface using standard HTTP methods.

In REST architecture, a REST Server provides access to resources and REST client accesses and makes these resources available. Here, each resource is identified by URIs or global IDs, and REST uses multiple ways to represent a resource, such as text, JSON, and XML. XML and JSON are nowadays the most popular representations of resources.

28. What is a RESTFul Web Services?
Mostly, there are two kinds of Web Services 

SOAP (Simple Object Access Protocol) – an XML-based method to expose web services.
Web services developed in the REST style are referred to as RESTful web services. These web services use HTTP methods to implement the concept of REST architecture. A RESTful web service usually defines a URI, Uniform Resource Identifier a service, provides resource representation like JSON and a set of HTTP methods.
29. What is a “Resource” in REST?
REST architecture treats any content as a resource, which can be either text files, HTML pages, images, videos or dynamic business information.
REST Server gives access to resources and modifies them, where each resource is identified by URIs/ global IDs.

30. What is the most popular way to represent a resource in REST?
REST uses different representations to define a resource like text, JSON, and XML.
XML and JSON are the most popular representations of resources.

31. Which protocol is used by RESTful Web services?
RESTful web services use the HTTP protocol as a medium of communication between the client and the server.

32. What are some key characteristics of REST?
Key characteristics of REST are

REST is stateless, therefore the SERVER has no status (or session data)
With a well-applied REST API, the server could be restarted between two calls, since all data is transferred to the server
Web service uses POST method primarily to perform operations, while REST uses GET for accessing resources.
33. What is messaging in RESTful Web services?
RESTful web services use the HTTP protocol as a communication tool between the client and the server. The technique that when the client sends a message in the form of an HTTP Request, the server sends back the HTTP reply is called Messaging. These messages comprise message data and metadata, that is, information on the message itself.

34. What are the core components of an HTTP request?
An HTTP request contains five key elements:

An action showing HTTP methods like GET, PUT, POST, DELETE.
Uniform Resource Identifier (URI), which is the identifier for the resource on the server.
HTTP Version, which indicates HTTP version, for example-HTTP v1.1.
Request Header, which carries metadata (as key-value pairs) for the HTTP Request message. Metadata could be a client (or browser) type, format supported by the client, format of a message body format, cache settings, and so on.
Request Body, which indicates the message content or resource representation.
35. What are the most commonly used HTTP methods supported by REST?
GET is only used to request data from a specified resource. Get requests can be cached and bookmarked. It remains in the browser history and haS length restrictions. GET requests should never be used when dealing with sensitive data.
POST is used to send data to a server to create/update a resource. POST requests are never cached and bookmarked and do not remain in the browser history.
PUT replaces all current representations of the target resource with the request payload.
DELETE removes the specified resource.
OPTIONS is used to describe the communication options for the target resource.
HEAD asks for a response identical to that of a GET request, but without the response body.
36. Can GET request to be used instead of PUT to create a resource?
The PUT or POST method should be used to create a resource. GET is only used to request data from a specified resource.

37. Is there any difference between PUT and POST operations?
PUT and POST operation are quite similar, except the terms of the result generated by them.

PUT operation is idempotent, so you can cache the response while the responses to POST operation are not cacheable, and if you retry the request N times, you will end up having N resources with N different URIs created on server.

Example for PUT and POST operations,  Below is an example:

Scenario: Let’s say we are designing a network application. Let’s list down few URIs and their purpose to get to know when to use POST and when to use PUT operations.

GET /device-management/devices : Get all devices
POST /device-management/devices : Create a new device

GET /device-management/devices/{id} : Get the device information identified by “id”
PUT /device-management/devices/{id} : Update the device information identified by “id”
DELETE /device-management/devices/{id} : Delete device by “id”

38. Which purpose does the OPTIONS method serve for the RESTful Web services?
The OPTIONS Method lists down all the operations of a web service supports. It creates read-only requests to the server.

39. What is URI? What is the main purpose of REST-based web services and what is its format?
URI stands for Uniform Resource Identifier. It is a string of characters designed for unambiguous identification of resources and extensibility via the URI scheme.

The purpose of a URI is to locate a resource(s) on the server hosting of the web service.
A URI’s format is <protocol>://<service-name>/<ResourceType>/<ResourceID>. 

40. What is payload in RESTFul Web services?
The “payload” is the data you are interested in transporting. This is differentiated from the things that wrap the data for transport like the HTTP/S Request/Response headers, authentication, etc.

41. What is the upper limit for a payload to pass in the POST method?
<GET> appends data to the service URL. But, its size shouldn’t exceed the maximum URL length. However, <POST> doesn’t have any such limit.

So, theoretically, a user can pass unlimited data as the payload to POST method. But, if we consider a real use case, then sending POST with large payload will consume more bandwidth. It’ll take more time and present performance challenges to your server. Hence, a user should take action accordingly.

42. What is the caching mechanism?
Caching is just the practice of storing data in temporarily and retrieving data from a high-performance store (usually memory) either explicitly or implicitly.

When a caching mechanism is in place, it helps improve delivery speed by storing a copy of the asset you requested and later accessing the cached copy instead of the original. 

 SOAP
43. What are SOAP Web services?
This is one of the fundamental Web services testing questions that you must know the answer. The SOAP (Simple Object Access Protocol) is defined as an XML-based protocol. It is known for designing and developing web services as well as enabling communication between applications developed on different platforms using various programming languages over the Internet. It is both platform and language independent.

44. How does SOAP work?
SOAP is used to provide a user interface that can be accessed by the client object, and the request that it sends goes to the server, which can be accessed using the server object. The user interface creates some files or methods consisting of server object and the name of the interface to the server object. It also contains other information such as the name of the interface and methods. It uses HTTP to send the XML to the server using the POST method, which analyzes the method and sends the result to the client. The server creates more XML consisting of responses to the request of user interface using HTTP. The client can use any approach to send the XML, like the SMTP server or POP3 protocol to pass the messages or reply to queries.

45. When to use SOAP API?
Use the SOAP API to create, retrieve, update or delete records, like accounts, leads, and user-defined objects. With more than 20 different calls, you can also use the SOAP API to manage passwords, perform searches, etc. by using the SOAP API in any language that supports web services.

46. How users utilize the facilities provided by SOAP?
PutAddress(): It is used to enter an address in the webpage and has an address instance on the SOAP call.
PutListing(): It is used to allow the insertion of a complete XML document into the web page. It receives the XML file as an argument and transports the XML file to XML parser liaison, which reads it and inserts it into the SOAP call as a parameter.
GetAddress(): It is used to get a query name and gets the result that best matches a query. The name is sent to the SOAP call in the form of text character string.
GetAllListing(): It is used to return the full list in an XML format.
47. What is the major obstacle users faced when using SOAP?
When using SOAP, users often see the firewall security mechanism as the biggest obstacle. This block all the ports leaving few like HTTP port 80 and the HTTP port used by SOAP that bypasses the firewall. The technical complaint against SOAP is that it mixes the specification for message transport with the specification for message structure.

48. What are the various approaches available for developing SOAP based web services?
There are two different methods available for developing SOAP-based web services, which are explained below:

Contract-first approach: the contract is first defined by XML and WSDL, and then Java classes are derived from the contract.
Contract-last approach: Java classes are first defined, and then the contract is generated, which is normally the WSDL file from the Java class.
“Contract-first” method is the most popular approach.

49. What are the elements of a SOAP message structure?
It is a common XML document that contains the elements as a SOAP message

Envelope: It is an obligatory root element that translates the XML document and defines the beginning and end of the message.

Header: It is an optional item which contains information about the message being sent.
Body: It contains the XML data comprising the message being sent.
Fault: It provides the information on errors that occurred while during message processing.
50. What are the syntax rules for a SOAP message?
Must use encoded XML
Envelope namespace must be used
Encoding namespace must be used
Must not consist of a DTD reference
Must not have XML processing instruction
51. What is the transport method in SOAP?
Application layer and transport layers of a network are used by SOAP; HTTP and SMTP are the valid protocol of the application layer used as the transport for SOAP. HTTP is more preferable, since it works well with the current Internet infrastructure, in particular with firewalls.
The SOAP requests can be sent using an HTTP GET method while the specification only contains details about HTTP POST.

52. What are some important characteristics of a SOAP envelope element?
SOAP message has a root Envelope element
Envelope is an obligatory part of the SOAP message.
If an envelope includes a header element, it should not contain more than one.
Envelope version will change if the SOAP version changes.
The SOAP envelope is indicated by the prefix ENV and the envelope element.
The optional SOAP encoding is also specified using a namespace and the optional encoding style element.
53. What are the major functionalities provided by the SOAP protocol class?
The SOAP protocol is used to provide simple access methods for all the applications available on the Internet, providing the following functionalities:

Call: A class which provides the main functionality for a remote method for which a call is needed. It is used to create the call() and to specify the encoding style of the registry that will be assigned when if necessary. This call() function is used by the RPC call, which represents the options of the call object.
Deployment Descriptor: A class used to provide the information about the SOAP services. It enables easy deployment without the need for other approaches.
DOM2 Writer: A class that serializes and uses DOM node as XML string to provide more functionalities.
RPC Message: A class used as the base class that calls and replies to the request submitted to the server.
Service Manager: A class that provides, lists and then outputs all SOAP services.
54. What are the web relation functionalities provided by SOAP protocol?
HTTPUtils: This provides the functionality of the POST method to safely meet the requirements.
Parameter: It is an argument for an RPC call used by both the client and the server.
Response: It is an object that represents an RPC reply from both client and server, but the result will not be displayed until after the method call.
TCPTunnel: It is an object that provides the ability to listen on a specific port and to forward all the host and port names.
TypeConverter: It helps to convert an object of one type into another type and this is called using the class in the form object.
55. How does the message security model allow the creation of SOAP more secure to use?
The security model includes the given security tokens. These tokens comprise digital signatures for protection and authentication of SOAP messages. Security tokens can be used to provide the bond between authentication secrets or keys and security identities. Security token uses the authentication protocols and an X.509 certificate to define the relationship between the public key and identity key. The signatures are used to verify the messages and their origin, generate knowledge to confirm the security tokens to bind the identity of a person to the identity of the originator. Security model prevents different attacks and can be used to protect the SOAP architecture.

56. What is the difference between top down & bottom up approach in SOAP Web services?
Top down SOAP Web services include creating WSDL document to create a contract between the web service and the client, with a required code as an option. This is also known as Contract-first approach. The top-down approach is difficult to implement because classes must be written to confirm the contract defined in WSDL. One of the benefits of this method is that both client and server code can be written in parallel.
Bottom up SOAP web services require the code to be written first and then WSDL is generated. It is also known as Contract-last approach. Since WSDL is created based on the code, bottom-up approach is easy to implement and client codes must wait for WSDL from the server side to start working.
57. What are advantages of SOAP?
SOAP is both platform and language independent.
SOAP separates the encoding and communications protocol from the runtime environment.
Web service can retrieve or receive a SOAP user data from a remote service, and the source’s platform information is completely independent of each other.
Everything can generate XML, from Perl scripts through C++ code to J2EE app servers.
It uses XML to send and receive messages.
It uses standard internet HTTP protocol.
SOAP runs over HTTP; it eliminates firewall problems. When protocol HTTP is used as the protocol binding, an RPC call will be automatically assigned to an HTTP request, and the RPC response will be assigned to an HTTP reply.
Compared to RMI, CORBA and DCOM, SOAP is very easy to use.
SOAP acts as a protocol to move information in a distributed and decentralized environment.
SOAP is independent of the transport protocol and can be used to coordinate different protocols.
58. What are disadvantages of SOAP?
SOAP is typically significantly slower than other types of middleware standards, including CORBA, because SOAP uses a detailed XML format. A complete understanding of the performance limitations before building applications around SOAP is hence required.

SOAP is usually limited to pooling and not to event notifications when HTTP is used for the transport. In addition, only one client can use the services of one server in typical situations.

If HTTP is used as the transport protocol, firewall latency usually occurs since the firewall analyzes the HTTP transport. This is because HTTP is also leveraged for Web browsing, and so many firewalls do not understand the difference between using HTTP within a web browser and using HTTP within SOAP.

SOAP has different support levels, depending on the supported programming language. For instance, SOAP supported in Python and PHP is not as powerful as it is in Java and .NET

59. What are the differences between SOAP and REST?
difference between soap and rest
60. SOAP or Rest APIs, which method to use?
SOAP is the heavyweight choice for Web service access. It provides the following advantages when compared to REST:
SOAP is not very easy to implement and requires more bandwidth and resources.
SOAP message request is processed slower as compared to REST and it does not use web caching mechanism.
WS-Security: While SOAP supports SSL (just like REST) it also supports WS-Security which adds some enterprise security features.
WS-AtomicTransaction: Need ACID Transactions over a service, you’re going to need SOAP.
WS-ReliableMessaging: If your application needs Asynchronous processing and a guaranteed level of reliability and security. Rest doesn’t have a standard messaging system and expects clients to deal with communication failures by retrying.
If the security is a major concern and the resources are not limited then we should use SOAP web services. Like if we are creating a web service for payment gateways, financial and telecommunication related work, then we should go with SOAP as here high security is needed.
REST is easier to use for the most part and is more flexible. It has the following advantages when compared to SOAP:
Since REST uses standard HTTP, it is much simpler.
REST is easier to implement, requires less bandwidth and resources.
REST permits many different data formats whereas SOAP only permits XML.
REST allows better support for browser clients due to its support for JSON.
REST has better performance and scalability. REST reads can be cached, SOAP based reads cannot be cached.
If security is not a major concern and we have limited resources. Or we want to create an API that will be easily used by other developers publicly then we should go with REST.
If we need Stateless CRUD operations then go with REST.
REST is commonly used in social media, web chat, mobile services and Public APIs like Google Maps.
RESTful service returns various MediaTypes for the same resource, depending on the request header parameter “Accept” as application/xml or application/json for POST and /user/1234.json or GET /user/1234.xml for GET.
REST services are meant to be called by the client-side application and not the end user directly.
ST in REST comes from State Transfer. You transfer the state around instead of having the server store it, this makes REST services scalable.
61. What are the factors that help to decide which style of Web services – SOAP or REST – to use?
Generally, REST is preferred due to its simplicity, performance, scalability, and support for multiple data formats.
However, SOAP is favorable to use where service requires an advanced level of security and transactional reliability.
But you can read the following facts before opting for any of the styles.
Does the service expose data or business logic? REST is commonly used for exposing data while SOAP for logic.
The requirement from clients or providers for a formal contract. SOAP can provide contract via WSDL.
Support multiple data formats.
Support for AJAX calls. REST can apply the XMLHttpRequest.
Synchronous and asynchronous calls. SOAP enables both synchronous/ asynchronous operations whereas REST has built-in support for synchronous.
Stateless or Stateful calls. REST is suited for stateless operations.
Security. SOAP provides a high level of security.
Transaction support. SOAP is good at transaction management.
Limited bandwidth. SOAP has a lot of overhead when sending/receiving packets since it’s XML based, requires a SOAP header. However, REST requires less bandwidth to send requests to the server. Its messages are mostly built using JSON.
Ease of use. REST based application is easy to implement, test, and maintain.

Thread

Native Thread Demon Thread Non-Demon Thread Native Thread: - Any Method/Thread which is mapped to OS is called Native Thread or Method. Demo...